下面是我的目录结构
E:\test\探查
目录探测包含加载dll文件( Probe.dll)的可执行Probing.exe。
代码是:
namespace Probing
{
class Program
{
static void Main(string[] args)
{
Assembly asm = Assembly.Load("Probe.dll");
if (asm != null)
{
Console.WriteLine("Assembly Probe is loaded");
}
else
{
Console.WriteLine("Assembly Probe is not loaded");
}
}
}
}dll文件位于子目录( e:\test\probing\CustomLibraries\Probe.dll )中(Probe.dl)。
我提供了Probing.exe.config文件,甚至App.config来定位程序集。
配置文件包含以下代码:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="CustomLibraries"/>
</assemblyBinding>
</runtime>
</configuration>我一直收到FileNotFound异常,直到我将dll保存在Bin目录中。
我需要你的帮助。(我正在使用Visual studio 2008 )
发布于 2009-09-19 07:28:46
尝试调试它的第一件事是setup Fusion logging -这样你就会看到检查过的目录。
探测只适用于你的应用程序目录下的子目录,所以,正如你所说,如果你的应用程序在...\bin中,而你的库在...\lib中,那么它就不会起作用--它们必须在...\bin\lib中。
您需要改用codebase
https://stackoverflow.com/questions/1448020
复制相似问题