.net - Can't load assembly I'm executing in -
i have case 2 c# projects need reference each other. assembly references assembly b. , assembly b uses reflection load a. works great in command line application.
but in word com addin getting following error:
could not load file or assembly 'windwardreports, version=15.0.142.0, culture=neutral, publickeytoken=34ffe15f4bbb8e53' or 1 of dependencies. system cannot find file specified. fusionlog === pre-bind state information === log: displayname = windwardreports, version=15.0.142.0, culture=neutral, publickeytoken=34ffe15f4bbb8e53 (fully-specified) log: appbase = file:///c:/program files (x86)/microsoft office/root/office16/ log: initial privatepath = null calling assembly : (unknown). === log: bind starts in default load context. log: using application configuration file: c:\\program files (x86)\\microsoft office\\root\\office16\\winword.exe.config log: using host configuration file: log: using machine configuration file c:\\windows\\microsoft.net\\framework\\v4.0.30319\\config\\machine.config. log: attempting download of new url file:///c:/program files (x86)/microsoft office/root/office16/windwardreports.dll. log: attempting download of new url file:///c:/program files (x86)/microsoft office/root/office16/windwardreports/windwardreports.dll. log: attempting download of new url file:///c:/program files (x86)/microsoft office/root/office16/windwardreports.exe. log: attempting download of new url file:///c:/program files (x86)/microsoft office/root/office16/windwardreports/windwardreports.exe.
this same code works fine in command line app.
the code: here code. (the syntax little weird because java code turned .net using ikvm, .net code when running).
cli.system.reflection.assembly assm; int indexsemi = outputbuilder.indexof(';'); if (indexsemi != -1) { string dllfilename = outputbuilder.substring (0, indexsemi); outputbuilder = outputbuilder.substring(indexsemi + 1); assm = cli.system.reflection.assembly.loadfile(dllfilename); } else assm = cli.system.reflection.assembly.getexecutingassembly(); cli.system.runtime.remoting.objecthandle hdl = cli.system.activator.createinstance(assm.get_fullname(), outputbuilder); return (ioutputbuilderengine) hdl.unwrap();
the system.activator.createinstance() what's throwing exception.
the code trying load dll file.
as can see fusion log, it's looking dll in 4 places, giving up:
- c:/program files (x86)/microsoft office/root/office16/windwardreports.dll
- c:/program files (x86)/microsoft office/root/office16/windwardreports/windwardreports.dll
- c:/program files (x86)/microsoft office/root/office16/windwardreports.exe
- c:/program files (x86)/microsoft office/root/office16/windwardreports/windwardreports.exe
seems dll located somewhere else. if need load disk, you'll need correct path. though if executing assembly, why can' use assembly.getexecutingassembly()
?
Comments
Post a Comment