So I have a CodeDOM compiler written in C# that's supposed to compile another application based on one of its resources. How would I change the target .NET framework of the resource (or of the outputted executable of the compiler)?
Asked
Active
Viewed 1,935 times
9
-
That depends on the compiler. – SLaks Aug 28 '11 at 16:53
2 Answers
7
You could pass options to the compiler using the following constructor:
var providerOptions = new Dictionary<string, string>();
providerOptions.Add("CompilerVersion", "v3.5");
var compiler = new CSharpCodeProvider(providerOptions);
...

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
3
You would need to specify it in a dictionary of settings for the compiler, such as:
var settings = new Dictionary<string,string>();
settings.Add("CompilerVersion", "v3.5");
var compiler = new CSharpCodeProvider(settings);
Unsurprisingly, Google already brings up a couple of examples of this, too; here and here.

Grant Thomas
- 44,454
- 10
- 85
- 129