I'm using Assembly.LoadFrom to load my dll and create an instance of it later.
Here is my problem. Sometime I can modify my dll. More precisely I delete it and create a new one with the same name and path. And when I instantiate it again and call methods I see that the instance being used is the first one.
If I close my application and call my method the good instance is being used.
So is there a way to deallocate resources or free the instance ? Here is my sample code
Assembly sampleAssembly = Assembly.LoadFrom(pathToDll);
MyClassEntity = sampleAssembly.CreateInstance("InstanceName") as MyClass;
MyClass is an abstract class.
Assemblies are loaded once and kept in memory. You'd have to load it into a separate AppDomain
and rid the domain to rid the loaded assembly.
See this link: http://msdn.microsoft.com/en-us/library/vstudio/ms173101.aspx
And this: How to reload an assembly for a .NET Application Domain?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.