tags:

views:

183

answers:

1

This is the error I get when I start my ASP.NET application in Mono:

System.InvalidOperationException: The process must exit before getting the requested information.
  at System.Diagnostics.Process.get_ExitCode () [0x00044] in /usr/src/mono-2.6.3/mcs/class/System/System.Diagnostics/Process.cs:149 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
  at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x001ee] in /usr/src/mono-2.6.3/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:267 
  at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00011] in /usr/src/mono-2.6.3/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:156 
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in /usr/src/mono-2.6.3/mcs/class/System/System.CodeDom.Compiler/CodeDomProvider.cs:119 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x0022f] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:804 
  at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:730 
  at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00254] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:624 
  at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:411 
  at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00050] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:356 
  at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x0003a] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:803 
  at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.Web.VirtualPath virtualPath, System.Type requiredBaseType) [0x0000c] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:500 
  at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x0001c] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.UI/PageParser.cs:161 
  at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web.UI/PageHandlerFactory.cs:45 
  at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00055] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1643 
  at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1624 
  at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x0075f] in /usr/src/mono-2.6.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1259 

I checked the source code indicated by the stacktrace, namely :CSharpCodeCompiler.cs:267

mcs.WaitForExit();
result.NativeCompilerReturnValue = mcs.ExitCode; //this throws the exception

I have no ideea if this is a bug in Mono, or if my App is doing something it shoudn't.

A simple "Hello World" application indicates that Mono is properly installed and working, It is just my app that is causing this exception to be thrown.

Hoping some enlighted minds have more on the issue

I'm runing Apache + mod_mono 2.6.3 on a CentOS 5.4 server.

What seems to make the difference between a simple "Hello World" and my application, is that there is a TON of stuff going on in Global.asax's Application_Start(). There are TCP sockets opened (and closed), tens of new threads spawned (arround 80) and various services started and closed. In a normal Windows + IIS server, the App would take up to 30 seconds to start. Why would this make a difference in Mono though ?

Edit:

Interestingly enough, one way to circumvent this problem is to move ALL the code from Application_Start into a separate async process:

void Application_Start()
{
 var t = new System.Threading.Thread(new ThreadStart(this.Async_Application_Start));
 t.Start();
}

void Async_Application_Start()
{
   ... Lots of stuff going on here..

   log('Async Application Start is done!'); // this actually gets logged, so the code DOES execute and end
}
+1  A: 

Try to look at this post.

Tomi
I saw that thread before; Alas, the accepted answer there, recommends to add a WaitForExit() before using the ExitCode; which is exactelly what the Mono code is doing anyway :-(
Radu094
Yes, but let's first try to find bug in the webapp code rather than in mono. Since you said there is a lot of stuff in Global.asax: are you creating some new processes there? Can you debug your webapp step by step in Application_Start()?
Tomi
I cannot debug the App from the IDE. I'm using VS2010 -> Publish -> manual copying the files via Samba. Yes, there are about 80 new processes started. Skiping the Application_Start() works fine, but I cannot remove it line by line, as the processes are interconected and depend on each other to run properly. There is no other exception thrown (I log each exception )besides this one.
Radu094
And between those processes - can't you have the same issue related to WaitForExit(), which is mentioned in the post? Can you try to debug your application using MonoDevelop?
Tomi
Radu094