(This is kind of a continuation of my question " How to use C # 6 with a website project type? ")
I am trying to use C # 7 features with Visual Studio 2017.
To do this, I upgraded Microsoft.Net.Compilersthe NuGet package to version 2.0.0-rc4 in existing ASP.NET WebForms 4.6.2.
It seems to work well from within Visual Studio 2017.
When deploying to my site, all I see is a yellow screen of death:
Compiler error with error code 255.
[Detailed compiler output]
Version Information: Microsoft.NET Framework Version: 4.0.30319; ASP.NET Version: 4.6.1590.0
The full source of the compiler is too long to be placed here (more than 30 thousand characters). I uploaded it to Pastebin .
My question is:
Is it possible to use the latest Roslyn compiler in an ASP.NET WebForms web application?
Update 1:
Of course, I included Microsoft.CodeDom.Providers.DotNetCompilerPlatformthe NuGet package and web.config entries as described here .
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
I even tried changing the parameter /langversion:6in the XML above /langversion:7without any other result.
Update 2:
The question and answer would probably be similar to using C # 7 functions from within ASP.NET MVC views inside Razor .cshtml files.
Update 3:
I broke through the event log and found them (German system, sorry):
Anwendung: csc.exe
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
Ausnahmeinformationen: System.IO.FileLoadException
bei Microsoft.CodeAnalysis.CommandLine.BuildClient.GetCommandLineWindows(System.Collections.Generic.IEnumerable'1<System.String>)
bei Microsoft.CodeAnalysis.CommandLine.DesktopBuildClient.Run(System.Collections.Generic.IEnumerable'1<System.String>, System.Collections.Generic.IEnumerable'1<System.String>, Microsoft.CodeAnalysis.CommandLine.RequestLanguage, Microsoft.CodeAnalysis.CommandLine.CompileFunc, Microsoft.CodeAnalysis.IAnalyzerAssemblyLoader)
bei Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[], System.String[])
bei Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[])
and
Exception information:
Exception type: HttpCompileException
Exception message: Eine externe Komponente hat eine Ausnahme ausgelöst.
bei System.Web.Compilation.AssemblyBuilder.Compile()
bei System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
bei System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed)
bei System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories)
bei System.Web.Compilation.BuildManager.CompileResourcesDirectory()
bei System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
bei System.Web.Compilation.BuildManager.CallAppInitializeMethod()
bei System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)