c# - Issue with AppDomain.CreateInstanceFromAndUnwrap -


i'm using appdomain.createinstancefromandunwrap() create object in different appdomain. couldn't work because kept throwing following error @ me:

could not load file or assembly 'comon, version=2.0.4960.27874, culture=neutral, publickeytoken=null' or 1 of dependencies. module expected contain assembly manifest.

however, found because tries load dll (which has same name .net assembly).

this how call method:

_script = (script)_appdomain.createinstancefromandunwrap(assembly.getexecutingassembly().location, "comon.scripting.script"); 

it works fine long there isn't native dll file same name .net assembly. why happen when i'm passing full path , filename of .net assembly?

when i'm passing full path , filename of .net assembly?

that's not how method works. first argument display name of assembly. not file name. msdn article recommends take @ assembly.fullname learn more display names.

so normal clr search rules in effect finding assembly. in gac first, in probing path appdomain. quirk didn't count on, clr not pay attention filename extension file. display name assembly doesn't specify it. considers exe , dll equivalent. can see in trace fuslogvw.exe, utility want use when have trouble this. , in other places, adding reference exe works fine example.

so finds comon.exe , that's kaboom, not managed assembly.

it isn't clear proper workaround might in case, other renaming assembly. when tinker appdomains typically want use appdomainsetup , set applicationbase or privatebinpath property.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -