如何正确访问当前AppDomain中的PrivateBinPath的财产? [英] How to properly access the PrivateBinPath property of the current AppDomain?
问题描述
由于AppDomain.AppendPrivatePath()已经过时,我试图找出如何指定PrivateBinPath在我的项目当前的AppDomain没有旋转了一个全新的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这将是确定的),我也知道我可以将其添加到我的应用程序的.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财产为null。
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屋!