Trying to unload unmanaged and managed third party dlls
Can you tell me please what is the best way to make garage collector to开发者_运维百科 unload unmanaged/managed third party dlls.
There is no way to unload managed assembly in .NET. The only option is to unload the entire AppDomain
. See also:
- Unloading an Assembly - Suzanne Cook's .NET CLR Notes
Managed code loads into Windows process into a 'default app domain', which is never unloaded until the process terminates.
CLR cant unload a single assembly; however a single AppDomain can be unloaded.
Calling AddRef & Release methods on ICLRRuntimeHost has no effects. [CLR is just like a COM Server]
Check MSDN link Why isn't there an Assembly.Unload method? http://blogs.msdn.com/b/jasonz/archive/2004/05/31/145105.aspx
To release unmanaged resources use IDisposable Interface.
A nice article on MSDN about Garbage Collection http://blogs.msdn.com/b/scottholden/archive/2004/12/28/339733.aspx
精彩评论