![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am a little stuck. An application that I am maintaining loads plug-ins but only uses the default app domain and thus cannot unload them. That's how it is. It also has its plug-in assemblies frequently updated and forces the user to restart the application each time. I have managed to get a default app domain to let me overwrite a plug-in's assembly via shadow copying, but for the life of me I cannot get the final part done -- that being loading up the new assembly. The old assembly is once again reloaded. Now I understand that I cannot unload an assembly from within an app domain without unloading the entire app domain. This is not an option with the default app domain short of restarting the application. But can I not simply load up a second differently versioned assembly into the same app domain? (They are not GAC'ed) Btw... I had to use deprecated calls to get this far since the AppDomain.CurrentDomain.SetupInformation property can in effect no longer be modified since the initialization is done. (It appears a change of heart took place in design at some point in time.) If not, what are my options? [STAThread] static void Main() { AppDomain.CurrentDomain.SetShadowCopyFiles(); AppDomain.CurrentDomain.SetShadowCopyPath(AppDomai n.CurrentDomain.BaseDirectory); Assembly workerAssembly = Assembly.Load(@"p1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); object lateBoundObj = workerAssembly.CreateInstance("Plugins.MyClass", true, BindingFlags.Default, null, null /*args*/, null, null); ... // time out... overwrite the assembly file now since we are using the shadow copy // re-load the new image workerAssembly = null; workerAssembly = Assembly.Load(@"p1, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null"); lateBoundObj = workerAssembly.CreateInstance("Plugins.MyClass", true, BindingFlags.Default, null, null /*args*/, null, null); So I am able to overwrite my DLL at the "timeout" point. But the Load call for the 1.0.0.1 version loads the 1.0.0.0 version again. Thx in advance. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |