如何正确访问当前 AppDomain 的 PrivateBinPath 属性? [英] How to properly access the PrivateBinPath property of the current AppDomain?

查看:36
本文介绍了如何正确访问当前 AppDomain 的 PrivateBinPath 属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 AppDomain.AppendPrivatePath() 已过时,我正在尝试弄清楚如何在我的项目中为当前 AppDomain 指定 PrivateBinPath,而无需启动一个全新的 AppDomain,并且以后能够访问它.

Since AppDomain.AppendPrivatePath() is obsolete, I'm trying to figure out how to specify a PrivateBinPath for the current AppDomain in my project without spinning up a whole new AppDomain, and being able to access it later.

我知道我可以在 AppDomainSetup 对象上设置 PrivateBinPath(如果我想创建一个新的 AppDomain 就可以了),而且我也知道我可以像这样将它添加到我的 app.config 中:

I know I can set the PrivateBinPath on an AppDomainSetup object (which would be ok if I wanted to create a new AppDomain), and I also know that I can add it to my app.config like so:

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath=".\AlternateLookupPath" />
    </assemblyBinding>
  </runtime>

但是,当将此条目添加到我的 app.config 时,AppDomain.CurrentDomain.SetupInformation.PrivateBinPath 属性为空.

However, when adding this entry to my app.config, the AppDomain.CurrentDomain.SetupInformation.PrivateBinPath property is null.

推荐答案

使用

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="AlternateLookupPath" />
    </assemblyBinding>
  </runtime>

根据 http://msdn.microsoft.com/en-us/library/823z9h8w.aspx privatePath 已经被解释为应用程序基目录的子目录"......所以我怀疑使用 .\ 有点混乱事情...

According to http://msdn.microsoft.com/en-us/library/823z9h8w.aspx the privatePath is already interpreted as "subdirectories of the application's base directory"... so I suspect that using .\ is somehow messing things up...

这篇关于如何正确访问当前 AppDomain 的 PrivateBinPath 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆