(这是怎样的一个后续行动,我的问题“How to use C# 6 with Web Site project type?”的)如何在Web应用程序中使用C#7 ASPX代码 - 页面之前?
我试图用C#7特点与Visual Studio 2017年
对于这一点,我已经更新的Microsoft.Net.Compilers
NuGet package to v2.0.0-rc4我现有的ASP.NET WebForms 4.6.2应用程序。
这似乎从Visual Studio中很好地工作2017年
当部署到我的网站,我看到的是死亡的黄屏:
编译器错误,错误代码255
[详细编译器输出]
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1590.0
完整的编译器源太长,无法在此张贴(超过30k字符),I've uploaded it to Pastebin。
我的问题:
是否有任何机会,以使用ASP.NET WebForms的Web应用程序中最新的罗斯林编译器?
更新1:
当然,我已经包括了Microsoft.CodeDom.Providers.DotNetCompilerPlatform
NuGet包和web.config中的条目,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>
我甚至试着在上面的XML没有不同的结果改变/langversion:6
参数/langversion:7
。
更新2:
可能的问题和答案将是使用C#7特点从.cshtml剃刀内的文件ASP.NET MVC的观点中的相似。
更新3:
我已经通过事件日志挖发现这些(德制,不好意思):
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[])
和:
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)
错误代码255是一个流行的错误,[这里](http://stackoverflow.com/questions/33989211/another-strange-asp-net-error-the-compiler-failed-with-error-code- 255)是一对夫妇的建议 – maccettura
@UweKeim啊,这个更新有一点帮助。 –
如果您想使用C#7功能,您可能需要考虑从WebForms移动到MVC 6。 C#7的好处大于尝试使用WebForms工作的维护开销?切换堆栈可能会更好。 –