【问题标题】:Visual Studio 2015 compiled ASP.NET MVC site template on Mono - System.InvalidOperationExceptionVisual Studio 2015 在 Mono 上编译 ASP.NET MVC 站点模板 - System.InvalidOperationException
【发布时间】:2016-09-28 03:18:36
【问题描述】:

最近我一直在尝试使用 Mono 来托管 ASP.NET MVC 应用程序,当尝试运行使用 Visual Studio 15 构建的模板应用程序时,我收到以下错误:

System.InvalidOperationException 没有进程与此关联 对象。

堆栈跟踪:

 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 服务器,操作系统是 Debian stretch。

为了检查这是否是服务器配置问题,我部署了一个使用 Visual Studio 13 创建的网站,它可以正常工作。为了设置服务器,我主要关注mono docs for nginx

我在 VS15 中创建的项目遇到的第一个问题是:

找不到文件“/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=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>

我怀疑这个问题在某种程度上与 VS15 使用 Roslyn 编译器有关。非常感谢任何帮助。

【问题讨论】:

    标签: asp.net-mvc nginx mono


    【解决方案1】:

    仔细检查错误信息并比较VS2013/2015项目,你应该看到CompilerPlatform位是罪魁祸首。

    Microsoft 主要为 .NET 设计它,因此它在 Mono 上不能很好地工作。要么将其从项目中删除以支持 Mono,要么完全切换到 .NET Core。

    【讨论】:

    • 我明白了。 .NET Core 似乎已经足够好了。我猜它没有 .NET 框架的完整功能,所以你有没有详细说明缺少什么的列表?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多