Hi all
I have a little problem with loading a assembly.
I am trying the following:
System.AppDomain local_AppDomain = System.AppDomain.CreateDomain("MyDomain");
System.Reflection.Assembly local_Assembly = local_AppDomain.Load("C:\Temp\sCONTROL_SSSP.dll");
I allways receive the following error on the line "local_AppDomain.Load":
"Could not load file or assembly 'C:\Temp\sCONTROL_SSSP.dll' or one of its dependencies. The system cannot find the file specified"
The path to the file and the file are 100 percent right ... :-)
Thanks for any comment!!
Best regards
Frank Uray
P.S. I can do System.Reflection.Assembly.LoadFrom("C:\Temp\sCONTROL_SSSP.dll")
but then I have the assembly not in a AppDomain and I am unable to unload ...

System.AppDomain and Assembly problem ...
BlackBean
Hi, Frank!
I suspect, you get the exception for the sCONTROL_SSSP.dll is outside the path the runtime searches for assemblies. You should better use AppDomainSetup class and set its AppDomainSetup.PrivateBinPath property to a relative directory, which resides under where the application resides and is specified by the AppDomainSetup.ApplicationBase property. So, if your application is in the C:\Temp, then the AppDomainSetup.ApplicationBase is to be set to the C:\Temp. Further, the sCONTROL_SSSP.dll should reside in, say, "C:\Temp\plugins" folder in which case the AppDomainSetup.PrivateBinPath property should be set to "plugins" value. In case, you need to enlist several directories you should separate them via the semicolon.
Example:
setup.ApplicationBase =
AppDomain.CurrentDomain.BaseDirectory;setup.PrivateBinPath =
"runtime";Then, use the setup as follows:
System.
AppDomain moduleDomain = System.AppDomain.CreateDomain("domainName", null, setup); // register this AppDomainRegarding your PS. As you know you cannot unload an Assembly, but you can unload an AppDomain. According to your sample, the instantiated assembly resides in the application's default AppDomain, so if you tried to unload it your application would exit. As a solution to this problem, you could create a separate AppDomain for each assembly (a plugin) so that you could easily unload each assembly if needed.
Gheatza
Hello Frank,
It may be an issue with the strong-name of the assembly.
You can find more information on debugging the assembly load failure at:
http://blogs.msdn.com/suzcook/archive/2003/05/29/57120.aspx
Hope that helps,
Stephen Fisher