I am using VS2008 with C#. I have an issue related to reflection. In my application I have a dropdown with 2 options. if user selects option1 assembly1 is loaded and invoke a method of loaded assembly. If the user selects option2, assembly2 gets loaded and a method of loaded assembly is invoked. now the issue is both the assemblies have most of the classes common. When the user selects option1 assembly1 loads and invoke a method. this method sets some static object. Now when user selects option2 it loads assembly2 and when that method is invoked it throws an exception due to the static method. I am not suppos to change the code of the assembly namespace. So the solution should be that the assembly should be unloaded after the method has been invoked. But it is impossible to unload an assembly once loaded.
My Findings. By searching on the net what I have learned is I have only one option that create a new appdomain and load the assembly in that appdomain and after the method invoke unload the assembly. i have implemented that but still I am getting the same issue. My guess is that I am not properly unloading the appdomain. i am writing down the code that I am using. Please have a look and let me know if I am making any mistake while operating with appdomains.
AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
View Complete Post