开发者

which dll contains generics extension methods?

I'm trying to dynamically compile s开发者_运维问答ource code using the CodeDom.Compiler stuff, which means I need to reference the basic assemblies manually. The source code that I am compiling must be able to access the basic list extension methods, for for instance, Max(), Min(), or Sum(), and probably lambda expressions as well.

When I compile the source, it says I'm missing the required assembly... currently I include System.dll, and System.Core.dll.

Which dll do I need to get the extension methods for generics?


Have a look at this blog post. You have to specify the compiler version manually when calling the CSharpCodeProvider constructor that receives a dictionary. Like this:

var provider = new CSharpCodeProvider(new Dictionary<string, string>{
                                       {"CompilerVersion", "v3.5"} });


The simple way to get past these type of hassles, is to look through Assembly.GetReferencedAssemblies(), and add references to the compiler that way. Then you know as long as your compiler compiles in Visual Studio, any code using those features will compile with your compiler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜