Two features of the framework seem to be conflicting in my ASP.NET
project and I'd appreciate any help on this.
1. I'm using CallContext to persist some values thru the remoting call.
In particular, I grab client's locale info so I can analyze it on the
remoting server.
2. I create a new AppDomain for dynamically compiled code, execute the
code and unload the domain after I'm done to free up the resources.
Both approaches work fine by themselves, however when put it all
together it bombs out. I got CallContextString class implementing
ILogicalThreadAffinative so I can put it into the CallContext. This
class resided in MyCallContext.dll. When I load new AppDomain with the
AppDomain.CreateInstance I get the error that MyCallContext.dll is not
found. That's understandable 'cause the Remoting needs the assembly to
deserialize the CallContext. I put the MyCallContext.dll into the
target directory of the new domain. Now the AppDomain loads and I can
do my stuff. However when I try to unload the AppDomain with
AppDomain.Unload(myDomain) I get the error again: MyCallContext.dll is
not found! And here's where I'm stuck and don't know what to do. I can
only guess that maybe Remoting is trying to serialize the CallContext
to send it further on the call during the AppDomain.Unload, and maybe
MyCallContext.dll is already unloaded at this point. Not sure really.
Any help is greatly appreciated.
|