I've a WCF service configured with Enterprise Library 5 "Logging Application Block", "Validation Application Block Integration with WCF" and "Exception Handling Application Block WCF Provider" and configured it using fluent API like this:
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();
Service Implementation:
[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... }
If I set the "IncludeExceptionDetailInFaults" property of my service debug behavior to false and call a service operation with an entity that won't validate correctly the following exception will be thrown in the service:
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl", name = "WCF Exception Shielding". Exception occurred while: while resolving. Exception is: InvalidOperationException - The type ExceptionPolicyImpl has multiple constructors of length 2. Unable to disambiguate.
But if I set the IncludeExceptionDetailInFaults to true a validation fault will be returned to the client.
Does anybody know what I'm missing?
Looks like you are trying to configure Ent Lib with Fluent API approach. I had similar error when I was trying configure Ent Lib with BOTH configuration files (web.config) and fluent api. If yes, you might try removing the config file variables and do only with fluent api. I found that this resolved the error for me. Let me know how it goes.