微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

原文地址:https://www.jb51.cc/csharp/93843.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐