我需要编译一些代码(我已经在做),但是用户必须能够从列表中选择.NET版本。
这是我目前的代码:
Dictionary<string, string> providerOptions = new Dictionary<string, string>
{
{"CompilerVersion", "v3.5"}
};
CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);
CompilerParameters compilerParams = new CompilerParameters
{
GenerateInMemory = true,
GenerateExecutable = false
};
compilerParams.ReferencedAssemblies.Add(Assembly.GetEntryAssembly().Location);
CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, script);
TL; DR: 如何将.NET版本传递给编译器?