我已经被配置为与企业库5“登录应用程序块” WCF服务“验证应用程序块集成WCF”和“异常处理应用程序块WCF提供商”并且配置为使用它流畅的API是这样的:类型ExceptionPolicyImpl具有长度为2的无法多个构造消除歧义
builder.ConfigureExceptionHandling()
// -----------------------------------------------------
// Preventing Enterprise Library Validation Block exceptions from getting shielded.
// -----------------------------------------------------
.GivenPolicyWithName("WCF Exception Shielding")
.ForExceptionType<FaultException<ValidationFault>>()
.ThenDoNothing()
// -----------------------------------------------------
// Shielding unhandled exceptions
// -----------------------------------------------------
.ForExceptionType<Exception>()
.LogToCategory("My Logging Category")
.WithSeverity(TraceEventType.Critical)
.ShieldExceptionForWcf(typeof(ServiceUnhandledFault), Resources.UnhandledException_ErrorMessage)
.ThenThrowNewException();
服务实现:
[ServiceContract]
[ValidationBehavior]
[ExceptionShielding("WCF Exception Shielding")]
public interface IMyService
{
[OperationContract]
[FaultContract(typeof(ValidationFault))]
[FaultContract(typeof(ServiceUnhandledFault))]
void InsertEntity(MyEntity file);
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall)]
public partial class MyService : IMyService { ...Implementation... }
如果我把我的服务的调试行为,假“IncludeExceptionDetailInFaults”属性和调用服务操作w ^第i个,将不能正确地验证以下异常的实体将在服务抛出:
Microsoft.Practices.Unity.ResolutionFailedException:依赖解析失败,TYPE =“Microsoft.Practices.EnterpriseLibrary.ExceptionHandling。 ExceptionPolicyImpl“,name =”WCF异常屏蔽“。 发生异常时:解析时。 例外是:InvalidOperationException - 类型ExceptionPolicyImpl具有长度为2的多个构造函数。无法消除歧义。
但是,如果我将IncludeExceptionDetailInFaults设置为true,验证错误将返回给客户端。
有谁知道我错过了什么?
我试图配置_Ent库4.1_为*旧的应用程序.NET CLR 3.5 2.0 APPPOOL *和_Ent库5.0_的*新应用.NET CLR 4.5 4.0 APPPOOL *有两个配置文件(web.config中)和我得到同样的错误。 – Kiquenet