c# - AppDomain Creation : Resolving "Could not load file or assembly" error -


this weird. here's code :

 appdomain newdomain = appdomain.createdomain("newdomain ", null,             new appdomainsetup             {                 applicationbase = @"d:\mydllfolderfullpath\"             });   assembly = newdomain.load("myassembly"); 

this throws "could not load file or assembly" error.
checked assembly's dll located under specified folder path, , name of assembly correct.

when copy myassembly.dll currentdomain's main folder, works !
behaves if applicationbase setting new appdomain has absolutely no effect , keep pointing current appdomain's appbase.

any ideas ?

i don't know want exactly...

but load dll appdomain , create instance, can this:

create appdomain. setup , security info optional parameters.

 var appdomain = appdomain.createdomain("a friendly name identify application", null, null); 

load assembly:

   var assemblyname = assemblyname.getassemblyname(@"c:\pathtoyourapp\consoleapplication1.exe")); 

create instance inside app domain:

var instance = (program)appdomain.createinstanceandunwrap(assemblyname.name, "consoleapplication1.program"); 

important: class want unwrap , access outside of app domain, had marked [serializable] attrbute!

[serializable] class program{} 

use event appdomain.unhandledexception exception handling outside appdomain.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -