最近我一直在尝试使用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 Server,操作系统是Debian延伸。
要检查这是否是服务器配置问题,我部署了一个使用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=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
我怀疑这个问题与VS15正在使用Roslyn编译器的事实有某种联系。非常感谢任何帮助。
答案 0 :(得分:0)
仔细检查错误消息并比较VS2013 / 2015项目,您应该看到CompilerPlatform位是罪魁祸首。
Microsoft主要针对.NET设计,因此它在Mono上运行效果不佳。您可以从项目中删除它以支持Mono或完全切换到.NET Core。