在machine.config中忽略.NET assemblyBinding配置 [英] .NET assemblyBinding configuration ignored in machine.config

查看:335
本文介绍了在machine.config中忽略.NET assemblyBinding配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,我需要能够根据它们的部分名称在GAC中加载程序集。为了做到这一点我已经添加以下到我的app.config文件:

I have a situation where I need to be able to load assemblies in the GAC based on their partial names. In order to do this I have added the following to my app.config file:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <qualifyAssembly partialName="MyAssembly"
                     fullName= "MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef"/>
  </assemblyBinding>
</runtime>

这完全符合我的想法。但是,如果我在我的machine.config文件中放置相同的元素,它似乎被忽略,我尝试加载MyAssembly时得到FileNotFoundExceptions。

This works exactly the way I want it to. However, if I place the same element in my machine.config file, it seems to be ignored, and I get FileNotFoundExceptions when trying to load MyAssembly.

以下是当元素在我的app.config中,并且绑定成功:

The following is the assembly binding log when the element is in my app.config, and the bind succeeds:

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\jon_scheiding\My Documents\Source\Testing\Test Projects 1\Cmd\bin\Debug\Testers.Cmd.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Partial reference qualified from config file. New reference: MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef.
LOG: Post-policy reference: MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789abcdef
LOG: Found assembly by looking in the GAC.
LOG: Binding succeeds. Returns assembly from C:\WINDOWS\assembly\GAC_MSIL\MyAssembly\1.0.0.0__b20f4683c1030dbd\MyAssembly.dll.
LOG: Assembly is loaded in default load context.

对比我的配置在machine.config中的日志, :

Contrast that with the log when my configuration is in machine.config, and the bind fails:

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\jon_scheiding\My Documents\Source\Testing\Test Projects 1\Cmd\bin\Debug\Testers.Cmd.vshost.exe.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Documents and Settings/jon_scheiding/My Documents/Source/Testing/Test Projects 1/Cmd/bin/Debug/MyAssembly.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/jon_scheiding/My Documents/Source/Testing/Test Projects 1/Cmd/bin/Debug/MyAssembly/MyAssembly.DLL.
LOG: Attempting download of new URL file:///C:/Documents and Settings/jon_scheiding/My Documents/Source/Testing/Test Projects 1/Cmd/bin/Debug/MyAssembly.EXE.
LOG: Attempting download of new URL file:///C:/Documents and Settings/jon_scheiding/My Documents/Source/Testing/Test Projects 1/Cmd/bin/Debug/MyAssembly/MyAssembly.EXE.
LOG: All probing URLs attempted and failed.

问题似乎是第四行,政策目前不适用于参考。

The problem seems to be the fourth line, "Policy not being applied to reference at this time." However, I can find very little documentation on what this message means, or how to address it.

如何让框架识别我的<运行时>元素?

How can I get the framework to recognize my <runtime> element?

提前感谢!

推荐答案

t从machine.config中读取qualifyAssebmly配置,它只从应用程序配置文件中读取它。

The framework won't read qualifyAssebmly configuration from machine.config, it only reads it from your application configuration file.

框架确实识别您的runtim元素,但它不识别qualifyAssembly元素。

The framework does recognize your runtim element, however it does not recognize the qualifyAssembly element.

这篇关于在machine.config中忽略.NET assemblyBinding配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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