c# – 在探测privatePath时使用绝对路径

在C#控制台应用程序中,我试图使用 <probing privatePath=""/>来指向不在我的应用程序子目录中的dll.我在用着:
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing privatePath="D:\Library\References" />
    </assemblyBinding>
</runtime>

这不起作用,因为privatePath正在我的应用程序中寻找子目录.有没有办法以这种方式使用绝对路径?如果没有,指向位于我应用程序之外的dll的最好方式是什么?我也试过使用< codebase>有一个文件:/// path,但仍然有一个System.IO.FileNotFound异常.

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity 
        name="MyLibrary" publicKeyToken="29989D7A39ACF230" />
      <codeBase
        version="2.0.0.0"
        href="http://file:///D:/Library/References/NLog.dll"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

但仍然有一个System.IO.FileNotFound异常.

谢谢!

解决方法

根据 MSDN

You can use the element only in machine configuration or
publisher policy files that also redirect the assembly version.

If you are supplying a code base hint for an assembly that is not
strong-named,the hint must point to the application base or a
subdirectory of the application base directory.

你可能试图在app.config中申请?

The directories specified in privatePath must be subdirectories of the application base directory.

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...