1

When implementing C#7 feature ($ - string interpolation) in my xcript, and calling CSharpCodeProvider.CompileAssemblyFromSource(), I receive the following error:

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 '$'

Construction:

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

Any idea how resolve ths issue?

Thanks!

pushkin
  • 9,575
  • 15
  • 51
  • 95
  • What version of `Microsoft.CSharp` do you have. Also, what does the code you're trying to compile look like? Because it looks like the code is getting compiled with C# 5 – James Parsons Jun 08 '18 at 19:45
  • 1
    Don't think you can use csc anymore as the error states (for C# 6 and up). I found for many things that I have, I've needed to install the Visual Studio Build Tools so I can get the current version of MSBuild without actually installing Visual Studio itself. https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017 – TyCobb Jun 08 '18 at 20:04
  • 2
    `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` – TyCobb Jun 08 '18 at 20:10
  • Download Roslyn – Patrick Hofman Jun 08 '18 at 21:02
  • Does this answer your question? [Using C# 6 features with CodeDomProvider (Roslyn)](https://stackoverflow.com/questions/31639602/using-c-sharp-6-features-with-codedomprovider-roslyn) – madrang Feb 11 '20 at 00:42

0 Answers0