none
C# Roslyn RRS feed

  • Question

  • Hi,

    Now I trying  using Microsoft.CodeAnalysis im my UWP app for creating some dll

    but when I try to create Metadata get exception 

       IEnumerable<MetadataReference> DefaultReferences =
                new[]
                {
                   MetadataReference.CreateFromFile(typeof(object).AssemblyQualifiedName)
                };

     Could not find file  bin\x86\Debug\AppX\System.Object, mscorlib, Version=4.0.0.0

    How to solve this ?

     


    Friday, February 5, 2016 3:58 PM

Answers

  • @Azat.Tazayan,

    It seems the Microsoft.CodeAnalysis does not have any document about "it can be supported on UWP platform". I guess it's right that currently you cannot use it in UWP forum.

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 16, 2016 11:20 AM
    Moderator

All replies

  • Hi ,

    Thank you for posting in MSDN forum.

    For this issue, i suggest you use SubInACL tool to repair file and registry permissions first and here is the download link:

    http://blogs.msdn.com/b/astebner/archive/2006/09/04/739820.aspx

    Besides, if there is something wrong with your VS, you need to use a healthy iso to repair, then please use http://aka.ms/vscollect   to gather the installation logs. After using it, you will find vslogs.cab from %temp% folder.

    Please upload the file to https://onedrive.live.com/   and share the link with us.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Tuesday, February 9, 2016 5:43 AM
    Moderator
  • Hi Lana Xu,

    Thanks for your replay.

    I checked my VS2015 work correctly, I build UWP app maybe I can't use  Microsoft.CodeAnalysis in  this type of app?

    Monday, February 15, 2016 7:05 AM
  • Here is my code 

    public class CreateDll
        {
    
            string syntaxTree = @"
            using System;
    
            namespace Compiler
            {
                public class Writer
                {
                    public string Write(string message)
                    {
                        return message;
                    }
                }
            }";
    
         
    
            private static readonly CSharpCompilationOptions DefaultCompilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary);
    
            public static SyntaxTree Parse(string text, string filename = "", CSharpParseOptions options = null)
            {
                var stringText = SourceText.From(text, Encoding.UTF8);
                return SyntaxFactory.ParseSyntaxTree(stringText, options, filename);
            }
    
            public CreateDll()
            {
    
                IEnumerable<MetadataReference> DefaultReferences =
               new[]
               {
                   MetadataReference.CreateFromFile(typeof(object).AssemblyQualifiedName),
                   MetadataReference.CreateFromFile("System.dll"))
               };
    
                var parsedSyntaxTree = Parse(syntaxTree, "", CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp6));
                    var compilation
                      = CSharpCompilation.Create("Test.dll", parsedSyntaxTree, DefaultReferences, DefaultCompilationOptions);
                    try
                    {
                        var result = compilation.Emit(@"C:\Users\###\AppData\Local\Packages\###\LocalState\Temp\Test.dll");
                        if (!result.Success)
                        {
                        }
                    }
                    catch (Exception ex)
                    {
    
                    }
            }

    and get this error  

    An exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.CodeAnalysis.dll but was not handled in user code
    
    Additional information: Could not find file \bin\x86\Debug\AppX\System.Object, mscorlib, Version=4.0.0.0,


    Monday, February 15, 2016 3:01 PM
  • @Azat.Tazayan,

    It seems the Microsoft.CodeAnalysis does not have any document about "it can be supported on UWP platform". I guess it's right that currently you cannot use it in UWP forum.

    Best regards,

    Barry


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 16, 2016 11:20 AM
    Moderator