Error after moving from ASP.Net 3.5 to 4.0 using Nginx + FastCGI-Mono-Server4

614 Views Asked by At

I'm using Nginx + FastCGI-Mono-Server to host a small asp.net web service. It is running just fine using FastCGI-Mono-Server2 (which is the .Net 2.0 version). I now need to upgrade the asp.net app to .net 4.0. That means I need to upgrade to FastCGI-Mono-Server4. I put all the correct files in place. It works! However, it consistently crashes with a mysterious error.

Here is the error:

Exception: System.Runtime.FatalException

Message: Object reference not set to an instance of an object.

StackTrace: at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext) at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result) at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult result) at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state) at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) at System.ServiceModel.Channels.SocketConnection.FinishRead() at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead) at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

InnerException: System.NullReferenceException

Message: Object reference not set to an instance of an object.

StackTrace: at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext) at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext) at System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state) at System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state) at System.Web.AspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state) at System.ServiceModel.Dispatcher.ThreadBehavior.BindCore(MessageRpc& rpc, Boolean startOperation) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)

I do have a IHttpAsyncHandler in the project. I wonder if it is somehow related to that. When I searched my error I found people (like this: wcf callback exception after updating to .net 4.0) recommending this attribute:

[CallbackBehavior(UseSynchronizationContext=false)]

From what I can tell that is a WCF thing and is unrelated to my asp.net web server. Any ideas would be appreciated!

EV

1

There are 1 best solutions below

0
On

Run

ln -s /opt/mono-3.2/lib/mono/4.0/fastcgi-mono-server4.exe /opt/mono-3.2/lib/mono/4.5/fastcgi-mono-server4.exe

and

use fastcgi server from 4.5 directory

/opt/mono-3.2/lib/mono/4.5/fastcgi-mono-server4.exe

If Mono is installed in other place, replace /opt/mono-3.2 with your mono prefix