Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using System.CodeDom.Compiler.CodeDomProvider to generate some code dynamically in my desktop application.

The code is generated as following.

var provider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("CSharp");
CompilerResults cr = provider.CompileAssemblyFromSource(compileParams, textCode);


I have read that the CSharp provider is just a wrapper on top of CSC.exe unlike Roslyn which exposes compiler features as an assembly functionality.

Question: If I'm using System.CodeDom namespace to generate code, does it mean that the client desktop where this application will run must have .NET SDK installed so the application can call CSC.exe.

Similarly, If Roslyn was being used to generate assembly, do I need to deploy/copy Roslyn assemblies as part of my application to the client desktop?

What I have tried:

Wrote a sample application which uses Roslyn and Code Dom.
Posted
Updated 13-Oct-17 5:45am
v4
Comments
Mehdi Gholam 13-Oct-17 10:39am    
No you don't need it, just the framework will do.
i_syed2000 13-Oct-17 11:06am    
Can you explain how that works. It seems to be working for me as well. But I'm little confused how it is working. Is it because the code generation are built into the .net run time itself?

1 solution

It looks like that "CSC.exe" does get installed as part of .Net Runtime. Found csc.exe in the following location.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\

When the codedom api is executed, the csc compiler is launched to compile the code into the assembly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900