gpt4 book ai didi

c# - 如何在 Visual Studio/C# 中为 DLL 依赖项定义工作目录

转载 作者:行者123 更新时间:2023-11-30 21:19:57 26 4
gpt4 key购买 nike

我有一个可执行文件,例如我从 C: 运行它。可执行文件引用了另一个目录中的一些 DLL,比方说 C:\MyDLLs。问题是,这些引用的 DLL 再次依赖于存储在另一个目录中的其他 DLL。我可以告诉 Visual Studio 去哪里寻找这些缺失的 DLL 吗?非常感谢!

最佳答案

您可以通过在配置中设置这些值来引用您应用的程序集加载规则之外的程序集。这是来自 this Microsoft KB article 的示例配置文件:

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyAssembly2" culture="neutral" publicKeyToken="307041694a995978"/>
<codeBase version="1.0.1524.23149" href="FILE://C:/Myassemblies/MyAssembly2.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

您使用 <codeBase>元素来告诉您的应用程序在哪里看。

您必须使程序集具有强名称(使用 sn.exe 工具)才能工作。

了解运行时如何运行也很有用 resolves assembly references也许你可以利用它而不是通过所有的箍来使用 <codeBase> .

关于c# - 如何在 Visual Studio/C# 中为 DLL 依赖项定义工作目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3560605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com