I am having a windows application in which I am loading and unloading the dll multiple times at run time and it works fine when i am using the same version dll. Problem arises when i try to load the same dll with different version at run time. For example: I loaded the dll "version1" and unloaded it and then i tried to load the same dll with different version say "version2", its not allowing me to load.
Please find below code for loading/unloading:
Loading Code:
if (this.libraryDomain != null)
{
AppDomain.Unload(this.libraryDomain);
}
// Re-create the AppDomain and create an instance of the Preview Bridge Module
this.libraryDomain = System.AppDomain.CreateDomain("PreviewLibraryDomain");
PreviewLibraryLoader previewLibraryLoader = this._previewLibraryDomain.CreateInstanceAndUnwrap(
"Preview.Library.Interface", "Preview.Library.Interface.PreviewLibraryLoader") as PreviewLibLoader;
this._bridgeModule = previewLibraryLoader.LoadPreviewLibrary(assemblyPath);
Unloading Code:
if (this.libraryDomain != null)
{
AppDomain.Unload(this.libraryDomain);
this.libraryDomain = null;
}