Wcf 类型ExceptionPolicyImpl具有多个长度为2的构造函数。无法消除歧义

Wcf 类型ExceptionPolicyImpl具有多个长度为2的构造函数。无法消除歧义,wcf,enterprise-library,Wcf,Enterprise Library,我使用企业库5“记录应用程序块”、“验证应用程序块与WCF集成”和“异常处理应用程序块WCF提供程序”配置了WCF服务,并使用fluent API对其进行了如下配置: builder.ConfigureExceptionHandling() // ----------------------------------------------------- // Preventing Enterprise Library Validation Blo

我使用企业库5“记录应用程序块”、“验证应用程序块与WCF集成”和“异常处理应用程序块WCF提供程序”配置了WCF服务,并使用fluent API对其进行了如下配置:

 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();
如果我将服务调试行为的“IncludeExceptionDetailInFaults”属性设置为false,并使用无法正确验证的实体调用服务操作,则服务中将引发以下异常:

Microsoft.Practices.Unity.ResolutionFailedException:依赖项解析失败,类型=“Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl”,名称=“WCF异常屏蔽”。 解析时发生异常。 异常为:InvalidOperationException-类型ExceptionPolicyImpl具有多个长度为2的构造函数。无法消除歧义。

但是如果我将IncludeExceptionDetailInFaults设置为true,则验证错误将返回给客户端


有人知道我遗漏了什么吗?

看起来您正试图用Fluent-API方法配置Ent-Lib。当我试图用配置文件(web.config)和fluentapi配置entlib时,我也遇到了类似的错误。如果是,您可以尝试删除配置文件变量,并且只使用fluent api。我发现这为我解决了这个错误。
让我知道进展如何。

看起来您正在尝试使用Fluent API方法配置Ent库。当我试图用配置文件(web.config)和fluentapi配置entlib时,我也遇到了类似的错误。如果是,您可以尝试删除配置文件变量,并且只使用fluent api。我发现这为我解决了这个错误。 让我知道进展如何。

我正在尝试为旧应用程序.net 3.5 clr 2.0 appPool配置Ent Lib 4.1,为新应用程序.net 4.5 clr 4.0 appPool配置Ent Lib 5.0,并使用两个配置文件(web.config),我尝试为旧应用程序.net 3.5 clr 2.0 appPool配置Ent Lib 4.1,为新应用程序.net 4.5 clr 4.0 appPool配置Ent Lib 5.0,并使用两个配置文件(web.config)配置相同的错误。
[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... }