Can any one help me in converting the .cs file into .dll programmatically?
Asked
Active
Viewed 1,027 times
-5
-
This has been asked, sorry I cant find the original question now. – leppie Aug 06 '10 at 11:47
-
6SO users are donating their free time here so things like 'ASAP' don't quite work... – Adrian Fâciu Aug 06 '10 at 11:47
-
Related: http://stackoverflow.com/questions/3188882/compile-and-run-dynamic-code-without-generating-exe – Joey Aug 06 '10 at 11:49
-
You logged here first time ever and want people to do your job, and fast! That's much more than just being lazy [which SO users quite got used to already]. At least take time to vote up the answers and select one as accepted to give credit to people that didn't get offended and helped you. – naugtur Aug 06 '10 at 11:57
-
@naugtur: He can't upvote anything until he gets 15 rep. – SLaks Aug 06 '10 at 12:24
2 Answers
3
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);

SLaks
- 868,454
- 176
- 1,908
- 1,964