由于AppDomain.AppendPrivatePath()已经过时,我试图弄清楚如何为我的项目中的当前AppDomain指定一个PrivateBinPath,而不需要启动一个全新的AppDomain,并且可以稍后访问它。如何正确访问当前AppDomain的PrivateBinPath属性?
我知道我可以设置一个AppDomainSetup对象的PrivateBinPath(如果我想创建一个新的AppDomain这将是确定的),我也知道我可以像这样把它添加到我的app.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath=".\AlternateLookupPath" />
</assemblyBinding>
</runtime>
但是,将此条目添加到我的app.config时,AppDomain.CurrentDomain.SetupInformation.PrivateBinPath属性为null。
我试过使用这个,但没有为我工作。 AppDomain.CurrentDomain.SetupInformation.PrivateBinPath属性仍然为空。 –
当通过app.config文件设置探测路径时,似乎AppDomain.CurrentDomain.SetupInformation.PrivateBinPath保持为空,但我能够确认在这种情况下探测路径仍然被实际使用。调用Assembly.Load并在我的探测路径中指定程序集的名称成功。 –
正如此评论中所述:http://stackoverflow.com/questions/33353420/appdomain-currentdomain-setupinformation-privatebinpath-is-null?noredirect=1#comment54508987_33353420 SetupInformation.PrivateBinPath对于主应用程序域始终为空。 – bitbonk