gpt4 book ai didi

c# - 如何使用 CSharpCodeProvider 定位 .net 4.5?

转载 作者:可可西里 更新时间:2023-11-01 02:59:08 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Using CSharpCodeProvider with .net 4.5 beta

对于 .net 3.5,我将 v3.5 传递给 CSharpCodeProvider,当我在 v4.5 应用程序中将 v4.5 传递给 CSharpCodeProvider 时,我得到 InvalidOperationException“找不到编译器可执行文件 csc.exe。 "

任何人都知道这里发生了什么,我做错了什么?

重现代码。 . .

using Microsoft.CSharp;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;

namespace Console1
{
class Program
{
static void Main(string[] args)
{
var options = new Dictionary<string, string>{{"CompilerVersion", "v4.5"}};
var cs = new CSharpCodeProvider(options);

var compilerParams = new CompilerParameters();

var r = cs.CompileAssemblyFromSource(compilerParams , "namespace ns { class program { public static Main(string[] args) { System.Console.WriteLine(\"Hello world\"); } } }");
}
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com