c# - 使用路径位于 app.config 中的 dll

标签 c# dll

我正在努力解决这个问题,但根本找不到太多相关信息。

我的配置文件如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
     <assemblyIdentity name="mydll"  culture="neutral"         publicKeyToken="3073773c0eff8935"/>
    <codeBase version="1.0.0.0" href="FILE://C:/users/James/Desktop/mydll2.dll"/>
  </dependentAssembly>
</assemblyBinding>
 </runtime>
  </configuration>

我已插入程序集的位置以及正确的公钥 token 和版本。

显然我的程序集不会位于 bin 文件夹中,我希望能够在需要时更改程序集的位置。我不知道如何在我的代码中引用它。如何从我的项目中调用此汇编函数?

我假设您需要以某种方式将对其的引用添加到项目中?

谢谢!

最佳答案

对于任何其他偶然发现这个问题的人...我现在已经做到了...

这里有一个教程...

https://web.archive.org/web/20070703223647/support.microsoft.com/kb/837908

通过使用 app.config 中的标签,将在运行时获取程序集的位置。

您应该做的就是添加对程序集的引用,并将“AssemblyIdentity name=”设置为添加到项目中的引用的名称。

右键单击引用 -> 属性,复制 local = false;

构建您的解决方案,然后您可以使用程序集的位置更新 app.config 文件。

关于c# - 使用路径位于 app.config 中的 dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11073709/

相关文章:

c# - Xamarin.Google.UserMessagingPlatform 指南?

C# Clickonce 应用程序先决条件 : Any SURE way to determine the list?

c# - IIS 不异步处理 Web Api 请求

.net - EmguCV cvextern System.DllNotFoundException

c# - 如何选择DataGridView中的所有行?

c# - 从TCPClient读取问题

c# - 在 C# 程序中使用多个用 C 编写的 DLL

c - Win VS2008 调用约定 : Delphi dll from c

Delphi:使用 LoadLibrary 加载 DLL 的奇怪行为

python - PyWin32 和 Python 3.8.0