Visual Studio 2015 编译 ASP.NET Mono 上的 MVC 站点模板 - System.InvalidOperationException
Visual Studio 2015 compiled ASP.NET MVC site template on Mono - System.InvalidOperationException
最近我一直在尝试使用 Mono 来托管 ASP.NET MVC 应用程序,当尝试 运行 使用 Visual Studio 15 构建的模板应用程序时,我收到以下错误:
System.InvalidOperationException No process is associated with this
object.
堆栈跟踪:
at System.Diagnostics.Process.EnsureState (System.Diagnostics.Process+State state) [0x0001e] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Diagnostics.Process.get_HasExited () [0x0000b] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Diagnostics.Process.EnsureState (System.Diagnostics.Process+State state) [0x00093] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Diagnostics.Process.get_ExitCode () [0x00000] in <affe4060066c42de8cdd6027cdb92b56>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
at System.CodeDom.Compiler.Executor.InternalExecWaitWithCapture (System.String cmd, System.String currentDir, System.CodeDom.Compiler.TempFileCollection tempFiles, System.String& outputName, System.String& errorName) [0x000f1] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture (System.IntPtr userToken, System.String cmd, System.String currentDir, System.CodeDom.Compiler.TempFileCollection tempFiles, System.String& outputName, System.String& errorName) [0x00007] in <affe4060066c42de8cdd6027cdb92b56>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Compile (System.CodeDom.Compiler.CompilerParameters options, System.String compilerFullPath, System.String arguments, System.String& outputFile, System.Int32& nativeReturnValue) [0x00071] in <57d777233c3f47cfbcc22a12ce3dc52b>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00170] in <57d777233c3f47cfbcc22a12ce3dc52b>:0 at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00048] in <57d777233c3f47cfbcc22a12ce3dc52b>:0
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x002f5] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00008] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, System.Boolean debug) [0x00264] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, System.Boolean debug) [0x0011c] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00063] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00040] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00006] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00179] in <80d482637b7943f8b4edcf91864a2ce4>:0
我在 Nginx 上使用 FastCGI Mono Server,OS 是 Debian stretch。
为了检查这是否是服务器配置问题,我部署了一个我用 Visual Studio 13 创建的网站,它运行没有任何问题。为了设置服务器,我主要关注 mono docs for nginx.
我在 VS15 中创建的项目遇到的第一个问题是:
Could not find file "/var/www/html/mono/bin\roslyn\csc.exe".
所以我使用了 MONO_IOMAP=all 设置(不确定这是否是解决此问题的正确方法)。之后我得到了我之前提到的异常。
两个站点(使用 VS13 构建的工作站点和模板站点)都以 .NET Framework 4.5 为目标。我在 Web.config 文件中可以找到的唯一大区别是这部分(在新站点中找到):
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.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.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
我怀疑这个问题与 VS15 使用 Roslyn 编译器这一事实有某种联系。非常感谢任何帮助。
仔细检查错误消息并比较 VS2013/2015 个项目,您应该看到 CompilerPlatform 位是罪魁祸首。
Microsoft 主要为 .NET 设计它,因此它在 Mono 上不能很好地工作。您可以将它从您的项目中移除以支持 Mono,或者完全切换到 .NET Core。
最近我一直在尝试使用 Mono 来托管 ASP.NET MVC 应用程序,当尝试 运行 使用 Visual Studio 15 构建的模板应用程序时,我收到以下错误:
System.InvalidOperationException No process is associated with this object.
堆栈跟踪:
at System.Diagnostics.Process.EnsureState (System.Diagnostics.Process+State state) [0x0001e] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Diagnostics.Process.get_HasExited () [0x0000b] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Diagnostics.Process.EnsureState (System.Diagnostics.Process+State state) [0x00093] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Diagnostics.Process.get_ExitCode () [0x00000] in <affe4060066c42de8cdd6027cdb92b56>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
at System.CodeDom.Compiler.Executor.InternalExecWaitWithCapture (System.String cmd, System.String currentDir, System.CodeDom.Compiler.TempFileCollection tempFiles, System.String& outputName, System.String& errorName) [0x000f1] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.CodeDom.Compiler.Executor.ExecWaitWithCapture (System.IntPtr userToken, System.String cmd, System.String currentDir, System.CodeDom.Compiler.TempFileCollection tempFiles, System.String& outputName, System.String& errorName) [0x00007] in <affe4060066c42de8cdd6027cdb92b56>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.Compile (System.CodeDom.Compiler.CompilerParameters options, System.String compilerFullPath, System.String arguments, System.String& outputFile, System.Int32& nativeReturnValue) [0x00071] in <57d777233c3f47cfbcc22a12ce3dc52b>:0
at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.FromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00170] in <57d777233c3f47cfbcc22a12ce3dc52b>:0 at Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Compiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00048] in <57d777233c3f47cfbcc22a12ce3dc52b>:0
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in <affe4060066c42de8cdd6027cdb92b56>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x002f5] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00008] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, System.Boolean debug) [0x00264] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, System.Boolean debug) [0x0011c] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00063] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00040] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00006] in <80d482637b7943f8b4edcf91864a2ce4>:0
at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00179] in <80d482637b7943f8b4edcf91864a2ce4>:0
我在 Nginx 上使用 FastCGI Mono Server,OS 是 Debian stretch。
为了检查这是否是服务器配置问题,我部署了一个我用 Visual Studio 13 创建的网站,它运行没有任何问题。为了设置服务器,我主要关注 mono docs for nginx.
我在 VS15 中创建的项目遇到的第一个问题是:
Could not find file "/var/www/html/mono/bin\roslyn\csc.exe".
所以我使用了 MONO_IOMAP=all 设置(不确定这是否是解决此问题的正确方法)。之后我得到了我之前提到的异常。
两个站点(使用 VS13 构建的工作站点和模板站点)都以 .NET Framework 4.5 为目标。我在 Web.config 文件中可以找到的唯一大区别是这部分(在新站点中找到):
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.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.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
我怀疑这个问题与 VS15 使用 Roslyn 编译器这一事实有某种联系。非常感谢任何帮助。
仔细检查错误消息并比较 VS2013/2015 个项目,您应该看到 CompilerPlatform 位是罪魁祸首。
Microsoft 主要为 .NET 设计它,因此它在 Mono 上不能很好地工作。您可以将它从您的项目中移除以支持 Mono,或者完全切换到 .NET Core。