There are several problems here. First, you cannot change the appbase of an
appdomain after it has been created. You must specify it as part of the
configuration before creating a new one, which wont help you i the default
appdomain.
If the assembly you want to load is in a directory beneath the current
appbase then you can add its relative path using the
AppendPrivatePath(relativePath), and then use Assembly.Load - the runtime
will probe the subdirectories for you. This is the best/easiest way to
handle it.
If the assembly is located somewhere other then beneath the appbase then you
will have to manually load the assembly using LoadFrom, LoadFile, or some
other Loadxxx variant. You will probably also need to hook the
AssemblyResolve event of the appdomain to resolve references made to types
with the assembly as the program executes. The downside of using any of the
Loadxxx APIs is that assemblies loaded using them do not get added to the
context the runtime uses to automatically resolve references.
"Stelios" <st************@avantisworld.com> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
Does anyone know how to dynamically load an assembly from a location other
that the working directory by using Assembly load method.
It is important to use the specific method because is the method used by
CLR to enforce version and security checking.
I have try by changing the appdomain APPBASE property but is not working
and i am wondering weather I am doing something wrong.
The code I use is the following
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.SetupInformation.ApplicationBase = "Location of hte assembly
to be loaded";
currentDomain.Load("AssemblyName;");
Thanks in advance