因此,我有一个用于Internet Explorer的托管BHO,它加载一个本机DLL,它依赖于一个混合模式DLL,而混合模式DLL又依赖于另一个托管DLL。
因此,依赖关系基本上是这样的:
IE.BHO.dll (Managed DLL)
|-> IE.Hook.dll (Native DLL)
|-> Core.Communication.CPP.dll (Mixed-Mode dll)
|-> Core.Communication.dll (Managed DLL)我已经加载了IE.Hook.dll,它在Core.Communication.CPP.dll中实例化一个类。但是只要Core.Communication.CPP.dll尝试使用Core.Communication.dll中的代码,我就会得到一个FileNotFoundException,说它找不到Core.Communication程序集。
它们都位于相同的目录中。Core.Communication.dll还依赖于protobuf-net,它也位于同一目录中。
要确保混合模式DLL可以加载托管DLL,我需要做些什么?
更新:
Fusion Log显示以下内容:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Core.Communication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Internet Explorer/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Internet Explorer/Core.Communication.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Internet Explorer/Core.Communication/Core.Communication.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Internet Explorer/Core.Communication.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Internet Explorer/Core.Communication/Core.Communication.EXE.因此,它似乎只在应用程序目录中查找,我猜这是有意义的。我想一定有一种方法可以让它在我的安装目录中查找,但我不确定是怎么做的。更改当前工作目录无济于事。有什么想法吗?
发布于 2013-12-03 05:28:25
所以我找到了AppDomain.CurrentDomain.AssemblyResolve,它似乎很适合我。不确定这是否是最好的™方式,所以我仍然对其他答案持开放态度:)
https://stackoverflow.com/questions/20336745
复制相似问题