K
Kunal
Hi friends,
I have tried to host a web service using HttpListener of .NET 2.0 (with
help from the article
http://msdn.microsoft.com/msdnmag/issues/04/12/ServiceStation/default.aspx).
The server runs fine, accepts and responds to requests just fine. I'm
using the synchronous model (GetContext). One of my requirements is to
log the incoming data to a text file. For this I create a separate
thread in the same namespace to send the data to via a message queue.
This thread logs the data to file while it is being processed
simultaneously. Data is written to the file correctly, the correct
response is generated and sent to the client. Around 2 secs after this
the server crashes with the exception -
System.AppDomainUnloadedException: The application domain in which the
thread was running has been unloaded.
Server stack trace:
at System.Threading.Thread.InternalCrossContextCallback(Context ctx,
IntPtr ctxID, Int32 appDomainID, InternalCrossContextDelegate
ftnToCall, Object[] args)
at
System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(Byte[]
reqStmBuff, SmuggledMethodCallMessage smuggledMcm,
SmuggledMethodReturnMessage& smuggledMrm)
at
System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage
reqMsg)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at HttpListenerLibrary.HttpListenerWrapper.ProcessRequest()
at HttpListenerLibrary.HttpListenerController.Pump() in C:\StarTeam
Original
code\easycare\Software\Release\SimulatorsDev\AcsSim\HttpListenerLibrary\HttpListenerLibrary.cs:line
166Error
I tried the following options -
1) I created the receiver thread in another namespace.
2) First I was sending data from ReadEntityBody overrided function. I
changed this to SendResponseFromMemory.
3) I changed different ways of writing to file.
But no success. Can anybody please help me and let me know what the
problem could be and how I can achieve what I want to ?
The server is compiled as a dll in my project.
Thanks,
Kunal
I have tried to host a web service using HttpListener of .NET 2.0 (with
help from the article
http://msdn.microsoft.com/msdnmag/issues/04/12/ServiceStation/default.aspx).
The server runs fine, accepts and responds to requests just fine. I'm
using the synchronous model (GetContext). One of my requirements is to
log the incoming data to a text file. For this I create a separate
thread in the same namespace to send the data to via a message queue.
This thread logs the data to file while it is being processed
simultaneously. Data is written to the file correctly, the correct
response is generated and sent to the client. Around 2 secs after this
the server crashes with the exception -
System.AppDomainUnloadedException: The application domain in which the
thread was running has been unloaded.
Server stack trace:
at System.Threading.Thread.InternalCrossContextCallback(Context ctx,
IntPtr ctxID, Int32 appDomainID, InternalCrossContextDelegate
ftnToCall, Object[] args)
at
System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(Byte[]
reqStmBuff, SmuggledMethodCallMessage smuggledMcm,
SmuggledMethodReturnMessage& smuggledMrm)
at
System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage
reqMsg)
Exception rethrown at [0]:
at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at HttpListenerLibrary.HttpListenerWrapper.ProcessRequest()
at HttpListenerLibrary.HttpListenerController.Pump() in C:\StarTeam
Original
code\easycare\Software\Release\SimulatorsDev\AcsSim\HttpListenerLibrary\HttpListenerLibrary.cs:line
166Error
I tried the following options -
1) I created the receiver thread in another namespace.
2) First I was sending data from ReadEntityBody overrided function. I
changed this to SendResponseFromMemory.
3) I changed different ways of writing to file.
But no success. Can anybody please help me and let me know what the
problem could be and how I can achieve what I want to ?
The server is compiled as a dll in my project.
Thanks,
Kunal