【问题标题】:Enterprise Library cast exception in web applicationWeb 应用程序中的企业库强制转换异常
【发布时间】:2012-01-15 22:24:42
【问题描述】:

我有一个使用 Enterprise Library 4.1 的 Web 应用程序。一位同事将 Web 应用程序使用的身份验证模块升级到 Enterprise Library 5.0。不幸的是,身份验证模块的升级版本包含我需要的新功能,所以我必须在我的项目中包含升级后的模块。我现在收到以下异常:

 [A]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection
 cannot be cast to [B]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection.
 Type A originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral,
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location
 'C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\4.1.0.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.
 Type B originates from 'Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral,
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location
 'C:\Windows\assembly\GAC_MSIL\Microsoft.Practices.EnterpriseLibrary.Common\5.0.414.0__31bf3856ad364e35\Microsoft.Practices.EnterpriseLibrary.Common.dll'.

有什么方法可以在我的应用中使用升级后的身份验证模块而不升级到 EL 5.0?

【问题讨论】:

    标签: c# enterprise-library enterprise-library-5 enterprise-library-4.1


    【解决方案1】:

    我认为您不能在一个应用程序中同时使用两个版本的企业库,至少在使用配置文件时不能。您看到的问题是由于 5.0 版试图从您的应用程序的配置文件中读取 4.1 版的配置部分。

    【讨论】:

    • 是的,我基本上得出了这个结论——或者至少没有人提出替代方案。我想这是鼓励组织范围内升级的一种方式,但我更希望它发生在商定的时间表上,而不是出其不意。我还发现 EntLib 5.0.414.0 有一个与 entlib.config 位置有关的错误,该错误在 5.0.505.0 版本中得到解决。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-05
    • 2011-04-12
    • 2011-09-25
    • 1970-01-01
    • 2015-03-14
    • 1970-01-01
    相关资源
    最近更新 更多