Dynamic load Assembly from specific path
Hi,
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?
Thanks
Jubin
Re: Dynamic load Assembly from specific path
Hi there,
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.