哪个 dll 包含泛型扩展方法?
我正在尝试使用 CodeDom.Compiler 动态编译源代码,这意味着我需要手动引用基本程序集。我正在编译的源代码必须能够访问基本列表扩展方法,例如 Max()、Min() 或 Sum(),可能还可以访问 lambda 表达式。
当我编译源代码时,它说我缺少所需的程序集...目前我包括 System.dll 和 System.Core.dll。
我需要哪个 dll 来获取泛型的扩展方法?
I'm trying to dynamically compile source 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个 博客发布。调用
CSharpCodeProvider
时必须手动指定编译器版本 接收字典的构造函数。像这样: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:解决这些麻烦的简单方法是查看 Assembly.GetReferencedAssemblies(),并以这种方式添加对编译器的引用。然后您就知道,只要您的编译器在 Visual Studio 中进行编译,任何使用这些功能的代码都将使用您的编译器进行编译。
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.