Application domain offload not returning?

My question is about the domain of the application created to load / unload the DLL. It all started with a need

Step-1 : load the dll
Step-2 : process that dll
Step-3 : Unload the dll

      

Since we cannot unload the DLL, creating an application domain is inevitable, and that's okay. So new steps:

Step-1 : Create a new app domain
Step-2 : load the dll
Step-3 : process that dll
Step-4 : Unload the Application domain

      

My problem is unloading. Sometimes it AppDomain.Unload("newDomain");

doesn’t come back, although I have been waiting for quite a long time. What could be the reason for the failure of the upload method? I read MSDN for the following explanation.

When a thread calls Unload, the target domain is marked for unload. A special thread tries to unload the domain, and all threads to the domain are aborted. If the thread is not interrupted, for example because it is executing unmanaged code, or because it finally executes a block, then after a while a CannotUnloadAppDomainException is thrown onto the thread that was originally called by Unload. If a stream that cannot be interrupted ends up end, the target domain is not unloaded. Therefore, in the .NET Framework, a 2.0 domain cannot be unloaded because it may not be able to terminate threads.

But I have some questions. 1) What is "Time Period" here? Can I install it?
2) MSDN states that .NET 2.0 environment does not quarante offload. How about .NET 4.0?
3) I'm sure there is no thread in the loaded dll. What other reason could there be?

I'm badly stuck, any help is appreciated :(

+3


source to share





All Articles