Exception handling Enterprise Library 6.0-异常处理块在配置源中找不到异常处理的配置部分
我们使用enterprise library 6.0-异常处理块和配置控制台来定义策略Exception handling Enterprise Library 6.0-异常处理块在配置源中找不到异常处理的配置部分,exception-handling,enterprise-library-5,Exception Handling,Enterprise Library 5,我们使用enterprise library 6.0-异常处理块和配置控制台来定义策略 The following code has been generated in app.config file for the defined policy <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="ex
The following code has been generated in app.config file for the defined policy
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<exceptionHandling>
<exceptionPolicies>
<add name="DataAccessPolicy">
<exceptionTypes>
<add name="All Exceptions" type="System.Exception, mscorlib, Version=4.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=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
exceptionMessage="An occured in the data 
access layer.
Please Contact the 
Admin with Error Id { }."
replaceExceptionType="Mindtree.Azure.PaymentGatewayExceptionHandler.DataAccessException, Mindtree.Azure.PaymentGatewayExceptionHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
</configuration>
I have the following code in my catch block, i am defining manager using configuration source factory and setting the exception manager
IConfigurationSource config = ConfigurationSourceFactory.Create();
ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
ExceptionPolicy.SetExceptionManager(factory.CreateManager())
bool rethrow = ExceptionPolicy.HandleException(ex,"DataAccessPolicy");
if(rethrow)
throw;
DataAccessPolicy is defined in the app.config file which uses the repalce handler
but the following error is thrown when debugging
你的.config是否在输出文件夹中?@AaronPalmer:嗨,我也面临着与此相同的问题。。你能解释一下输出文件夹是什么意思吗?我试图在数据层的类库中使用这个。我的建议基本上是一个健全的检查。确保在运行ie:\Bin\Debug时,无论输出放置在何处,都实际包含.config文件,并定义了预期的configSection。要检查的另一件事是,configSection中的版本信息确实是运行时可用的版本,无论是GAC还是本地复制的。@AaronPalmer:非常感谢它工作正常。。。在一些投票中回报您的支持:
Any Help would be appereciated. Thanks in advance