How to Compile the .cs file into .dll in C#.Net programatically?

前端 未结 2 1570
感动是毒
感动是毒 2021-01-29 16:48

Can any one help me in converting the .cs file into .dll programmatically?

相关标签:
2条回答
  • 2021-01-29 16:55

    Take a look at the CSharpCodeProvider class.

    0 讨论(0)
  • 2021-01-29 16:58

    You're looking for the CSharpCodeProvider class.

    For example:

    var compiler = new CSharpCodeProvider(new Dictionary<string, string> { { "CompilerVersion", "v4.0" } });
    var options = new CompilerParameters { OutputAssembly = path);
    var results = compiler.CompileAssemblyFromFile(options, sourceFile);
    
    0 讨论(0)
提交回复
热议问题