Loading an assembly generated by the Roslyn compiler

后端 未结 5 593
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 17:54

I\'m generating a Greeter.dll using the Roslyn compiler. My problem occurs trying to load the DLL file.

Here\'s the code:

using System;

using Rosly         


        
5条回答
  •  一整个雨季
    2020-12-31 18:24

    There is a new API for the References that looks like this:

    var compilation = Compilation.Create(outputFile,
        syntaxTrees: new[] { syntaxTree },
        references: new[] {
            new MetadataFileReference(typeof(object).Assembly.Location),
            new MetadataFileReference(typeof(Enumerable).Assembly.Location),
        },
        options: new CompilationOptions(OutputKind.DynamicallyLinkedLibrary)
    );
    

    This is with the latest Roslyn-CTP 2012 in Sept...

提交回复
热议问题