编程语言
首页 > 编程语言> > c# – 使用Codebase加载程序集

c# – 使用Codebase加载程序集

作者:互联网

基于this question,我尝试使用< codebase>找到外部组件.现在,当我运行该程序时,我收到一条错误消息,指出私有程序集位于appbase之外.我该如何解决这个问题?我看到的一个建议就是签署集会.我做了这个,但后来我的程序找不到程序集.当我取消签名时,我会在appbase外部出错.如何使用< codebase>加载位于其他位置的程序集而不是安装到GAC? (探测也不起作用,似乎它仍然必须存在于应用程序文件夹中)
我的配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>

        <assemblyIdentity name="NGameHost"

                          culture="neutral" />
        <codeBase version="1.0.0.0" 
                  href="C:/Program Files/NetworkGame3/api/NGameHost.exe"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>

解决方法:

If the assembly is a private assembly, the codebase setting must be a path relative to the application’s directory.

(自MSDN起)

标签:c,console-application,net-assembly,assembly-signing,codebase
来源: https://codeday.me/bug/20190613/1234857.html