VS 2017,直接CSharpCodeProvider使用C#7

时间:2018-06-08 19:42:01

标签: c# csharpcodeprovider

在我的xcript中实现C#7功能($ - 字符串插值)并调用CSharpCodeProvider.CompileAssemblyFromSource()时,收到以下错误:

E:\src\*****\****\bin\Debug> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" 
/t:library /utf8output /R:"E:\***\***\Main\ConsoleApp1\bin\Debug\***.dll" 
/R:"Microsoft.CSharp.dll" /R:"System.Core.dll" 
/R:"System.Data.DataSetExtensions.dll" /R:"System.Data.dll" 
/R:"System.Data.Linq.dll" 
/R:"System.dll" 
/R:"System.Xml.dll" 
/R:"System.Xml.Linq.dll" 
/R:"EntityFramework.dll" 
/out:"E:\***\***\Main\***RuleEngine\_DynamicDll\***RuleEngine.dll" 
/D:DEBUG /debug+ 
/optimize-  "E:\***\***\Main\***RuleEngine\_DynamicDll\TempFiles\5jdr2zw0.0.cs"
 Microsoft (R) Visual C# Compiler version 4.7.2558.0  for C# 5
 Copyright (C) Microsoft Corporation. All rights reserved.
 This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
 E:\***\***\Main\***RuleEngine\_DynamicDll\TempFiles\5jdr2zw0.0.cs(549,35): error CS1056: Unexpected character '$'

 0) E:\***\***\Main\***RuleEngine\_DynamicDll\TempFiles\5jdr2zw0.0.cs(549,35) 
 : error CS1056: Unexpected character '$'

结构:

_csc = new CSharpCodeProvider(new Dictionary<string, string>() { { 
"CompilerVersion", "v4.0" } });

知道如何解决这个问题?

谢谢!

0 个答案:

没有答案