Prev: Creating a setup that automatically installs .NET
Next: .NET 3.5 - System.Reflection.Assembly does not release object (DLL
From: Wolfixx on 5 Apr 2010 07:46 Hello, Does anyone of you know how I can force vb.net to remove the handle of a local DLL which I used beforehand with Reflection. Here is a fragment of the code. I have a base class and a derived class. This app only knows the base class and creates an Instance of the derived class by using Reflection which works fine. The only problem I have is that the local DLL file is blocked (I can't delete it) as long as I don't close the Application Dim GetCustomModule as BaseClass Dim dll As Assembly = Assembly.LoadFrom("c:\tools\DerivedCass.dll") For Each assemblytype As System.Type In dll.GetExportedTypes If assemblytype.ToString = "tools" Then GetCustomModule = DirectCast(Activator.CreateInstance(assemblytype), BaseClass) End If Next .... do something with the Class and then get rid of it .... dll = Nothing 'now the file c:\tools\DerivedCass.dll is still locked and I can't delete it. Forcing Garbage Collector to run doesn't help at all. I can see through Sysinternals\ProcessExplorer that AppName.vshost.exe has still a handle on that file. Thanks for any help Wolfgang |