【问题标题】:Using <codebase> element in app.config在 app.config 中使用 <codebase> 元素
【发布时间】:2009-12-17 01:59:12
【问题描述】:

我打算在我的 .NET 3.5 Windows 应用程序的 bin 文件夹以外的文件夹中保留几个 dll。我不确定如何使用代码库元素或探测元素来指定正确的路径。这就是我现在在 app.config 文件中的内容,

<runtime>
 <assemblyBinding>
  <dependentAssembly>
    <assemblyIdentity name="CommonLib" publicKeyToken="f0b5026b59d5645e"   
     culture="neutral" />
    <codeBase version="1.0.0.0" href="SharedFolder\CommonLib.dll" />
  </dependentAssembly>
 </assemblyBinding>
</runtime>

我明白了,在运行时无法加载程序集错误。看来我在配置文件中做错了什么。 SharedFolder 是添加到项目中的文件夹。

【问题讨论】:

    标签: .net codebase probing


    【解决方案1】:

    codeBase 元素似乎是用于获取带有 URL 的文件,您是否尝试过使用 probing element

    <runtime>
     <assemblyBinding>
      <dependentAssembly>
        <assemblyIdentity name="CommonLib" publicKeyToken="f0b5026b59d5645e"   
         culture="neutral" />
      </dependentAssembly>
      <probing privatePath="SharedFolder"/>
     </assemblyBinding>
    </runtime>
    

    【讨论】:

    • 我是这么认为的。您能否快速编辑我添加的运行时元素以使用其中的探测元素?我试过了,但可能我没有正确使用它。
    【解决方案2】:

    谢谢尤里。问题是路径。 privatePath 值需要是 .NET 运行时可以到达的路径。我试图“SharedFolder”,它不在 Debug 文件夹内,它直接在项目文件夹下。

    【讨论】:

    • 您应该标记一个答案(如果需要,还可以添加评论)而不是在这里创建另一个答案...
    猜你喜欢
    • 2015-03-14
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    • 2016-10-01
    • 1970-01-01
    • 2018-10-01
    相关资源
    最近更新 更多