将企业库注册到GAC后,无法解决类型运行时错误 [英] Cannot resolve type runtime error after registering the Enterprise Library into the GAC

查看:87
本文介绍了将企业库注册到GAC后,无法解决类型运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我致力于将企业库程序集注册到全局程序集缓存(GAC)中。我正在使用用自己的密钥签名的企业库5.0版,并且在许多.NET 4.0应用程序中使用了程序集。

I worked on registering the Enterprise Library assemblies into the Global Assembly Cache (GAC). I am using version 5.0 of the Enterprise Library that I signed with my own key, and I am using the assemblies in a number of .NET 4.0 applications.

成功注册后将企业库组装到GAC中,应用程序将显示以下消息:

After successfully registering the Enterprise Library assemblies into the GAC, the application started with this message:

类型'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling无法解决。请验证拼写正确或提供了完整的类型名称。

The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

当我从GAC取消注册企业库程序集时,应用程序将返回正常运行状态。

When I unregister the Enterprise Library assemblies from the GAC, the application returns to normal operating conditions.

当企业库程序集已注册到GAC中时,导致应用程序失败的原因是什么?

What is causing the application to fail when the Enterprise Library assemblies are registered into the GAC?

推荐答案

这需要花很多时间才能弄清楚发生了什么。事实证明,企业库在内部使用部分名称来动态加载类型。在这种情况下,企业库正尝试动态加载Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter,因为它出现在配置文件中。

This required quite a bit of hunting to figure out what happened. As it turns out, the Enterprise Library internally uses partial names to load type dynamically. In this case, the Enterprise Library is trying to load Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter dynamically because it appears in the configuration file.

解决部分名称引用在运行时,只需在配置文件中输入qualifiedAssembly元素(请参见< qualifyAssembly>元素(在MSDN文档中)。

To get around partial name references at runtime, simply enter a qualifyAssembly element in the configuration file (see <qualifyAssembly> Element in the MSDN documentation).

在我来说,我需要输入的只是以下条目:

In my case, all I needed to enter was this entry:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <qualifyAssembly partialName="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" 
                       fullName="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </assemblyBinding>
</runtime>

这篇关于将企业库注册到GAC后,无法解决类型运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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