【问题标题】:How to Compile the .cs file into .dll in C#.Net programatically?如何以编程方式在 C#.Net 中将 .cs 文件编译为 .dll?
【发布时间】:2010-08-06 11:44:50
【问题描述】:

任何人都可以帮助我以编程方式将 .cs 文件转换为 .dll 吗?

【问题讨论】:

  • 这个已经被问到了,抱歉我现在找不到原来的问题了。
  • 所以用户在这里贡献他们的空闲时间,所以像“尽快”这样的东西不太管用......
  • 您第一次登录这里并希望人们快速完成您的工作!这不仅仅是懒惰[SO用户已经习惯了]。至少花时间对答案进行投票并选择一个被接受的答案,以表扬那些没有被冒犯并帮助过你的人。
  • @naugtur:在获得 15 个代表之前,他不能投票赞成任何事情。

标签: c#-4.0


【解决方案1】:

您正在寻找CSharpCodeProvider class

例如:

var compiler = new CSharpCodeProvider(new Dictionary<string, string> { { "CompilerVersion", "v4.0" } });
var options = new CompilerParameters { OutputAssembly = path);
var results = compiler.CompileAssemblyFromFile(options, sourceFile);

【讨论】:

    【解决方案2】:

    看看CSharpCodeProvider 类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-09
      • 2012-02-19
      • 2012-12-16
      • 1970-01-01
      • 2018-05-10
      • 1970-01-01
      • 2019-06-10
      • 1970-01-01
      相关资源
      最近更新 更多