April 6th, 2010, 04:28 PM
Dynamic load Assembly from specific path
I have been dynamically loading assemblies using this:
// paramType is "NamesSpace.TypeName, AssemblyName"
myType = Type.GetType(paramType);
myObj = Activator.CreateInstance(myType);
This works with my assembly being in the same bin path as my app. Now if there is a possibility that the assemblies can be loading from a different path, is there a way i can just change the paramType and load it from a different path without code changes.
If i need to make code changes to do like an Assembly.Load instead, can it support both versions with same code - local load and path load of assembly?
April 6th, 2010, 05:40 PM
Re: Dynamic load Assembly from specific path
Here is an option that you can apply without any code changes...I assume you wouldn't want to put the assembly into the GAC in which case you would go for the option #2. In essence the reason why it will work in all scenarios is because you can change the configuration in the config file and leave the code as it is. Without the configuration it will work for the assemblies in the bin folder. With the configuration your assembly could be anywhere.
Last edited by nelo; April 6th, 2010 at 05:42 PM.
Tags for this Thread
Click Here to Expand Forum to Full Width