gpt4 book ai didi

wcf - 无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.ExceptionHandling”

转载 作者:行者123 更新时间:2023-12-01 02:51:36 28 4
gpt4 key购买 nike

当我为 wcf 应用程序添加企业库 5.0 文件 MS.Practices.EnterpriseLibrary.ExceptionHandling.dll 时,出现以下错误。

An error occurred creating the configuration section handler for exceptionHandling: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.


 <exceptionHandling>
<exceptionPolicies>
<add name="Global Policy">
<exceptionTypes>
<add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="None">
<exceptionHandlers>
<add name="Wrap Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" exceptionMessage="Global Message." wrapExceptionType="ExceptionHandlingQuickStart.BusinessLayer.BusinessLayerException, ExceptionHandlingQuickStart.BusinessLayer" />
<add name="Custom Handler" type="AppMessageExceptionHandler, ExceptionLibraryForWCF"/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
<add name="Handle and Resume Policy">
<exceptionTypes>
<add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="None">
<exceptionHandlers/>
</add>
</exceptionTypes>
</add>
<add name="Propagate Policy">
<exceptionTypes>
<add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow">
<exceptionHandlers/>
</add>
</exceptionTypes>
</add>
<add name="Replace Policy">
<exceptionTypes>
<add name="SecurityException" type="System.Security.SecurityException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException">
<exceptionHandlers>
<add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" exceptionMessage="Replaced Exception: User is not authorized to peform the requested action." replaceExceptionType="System.ApplicationException, mscorlib"/>
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
<add name="Wrap Policy">
<exceptionTypes>
<add name="DBConcurrencyException" type="System.Data.DBConcurrencyException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="ThrowNewException">
<exceptionHandlers>
<!--<add name="Wrap Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" exceptionMessage="Wrapped Exception: A recoverable error occurred while attempting to access the database." wrapExceptionType="ExceptionHandlingQuickStart.BusinessLayer.BusinessLayerException, ExceptionHandlingQuickStart.BusinessLayer" /> -->
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>

下面是我的异常处理的 web.config 声明







































-->

最佳答案

您的 web.config 实际上不在帖子中。

无论如何,您的配置文件中都有对 Entlib 2.0 的引用。您需要更新以指向 Entlib 5 版本号和公钥 token 。它可能在您的元素中,但如果它在那里,如果您文件的其余部分也有错误的版本#,我不会感到惊讶。

[进一步反射(reflection)的更新]

实际上,根据错误消息,还有另一种可能性 - 运行时在加载时正在查找 2.0 程序集而不是 5.0 程序集。仔细检查所有程序集引用,并检查您的 bin 目录 - 确保其中包含正确的程序集。

您还可以尝试在 Web 服务器上运行 fuslogvw 工具 - 它会告诉您运行时尝试加载哪些程序集,以及在何处查找它们。

关于wcf - 无法加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.ExceptionHandling”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4753950/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com