在 C# 控制台应用程序中,我尝试使用 <probing privatePath=""/>
指向不在我的应用程序子目录中的 dll。我正在使用:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="D:\Library\References" />
</assemblyBinding>
</runtime>
这不起作用,因为 privatePath 正在我的应用程序中寻找子目录。有没有办法以这种方式使用绝对路径?如果不是,指向位于我的应用程序外部的 dll 的最佳方法是什么?我也尝试使用 <codebase>
用file:///
路径,但仍然有一个 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.
关于c# - 在探测 privatePath 时使用绝对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9536256/