gpt4 book ai didi

c# - 从其他文件夹加载dll

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:54 25 4
gpt4 key购买 nike

我的 C# 应用程序正在加载 C# dll。这个c#dll通过DllImport加载一个c dll。我希望这两个 dll 都存在于当前工作目录的其他文件夹中。但我不想修改它的环境变量。我试过 SetDllDirectory 但无法加载这些 dll。你知道我该怎么做吗?

最佳答案

尝试将此添加到您的配置文件中:

    <?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="FolderName;OtherFolderName"/>
</assemblyBinding>
</runtime>
</configuration>

这些文件夹必须是您的应用程序目录的子目录。

关于c# - 从其他文件夹加载dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11411877/

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