The type ExceptionPolicyImpl has multiple constructors of length 2. Unable to disambiguate.

Topics: Exception Handling Application Block, Policy Injection Application Block
Mar 3, 2011 at 10:08 AM

I have such an exception when using Policy Injection and Exception Handling Blocks when resolving an object which has [ExceptionCallHandler("Policy")] attribute.

Here is my config file:

  <exceptionHandling>
    <exceptionPolicies>
      <add name="Policy">
        <exceptionTypes>
          <add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
              postHandlingAction="NotifyRethrow" />
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  
  <policyInjection>
    <policies>
      <add name="Policy1" order="0">
        <handlers>
          <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.PolicyInjection.ExceptionCallHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
              exceptionPolicyName="Policy" name="Exception Handling Call Handler" order="0"/>
        </handlers>
      </add>
    </policies>
  </policyInjection>

My class:

    public class A : MarshalByRefObject
    {
        [ExceptionCallHandler("Policy")]
        public void gg()
        {
            throw new Exception("rrrr");
        }
    }
This also can be reproduced when running:
ExceptionPolicyImpl myPolicy = container.Resolve<ExceptionPolicyImpl>("Policy");

Basically i'm migrating from EntLib 4.1 to 5.1. In v4.1 everything worked just fine. I followed the instructions in Microsoft Migration Guidelines.

What should i do to be able using Policy Injection, Exception Hanling Blocks with ExceptionCallHandlerAttribute?

Thanks in advance.

Mar 3, 2011 at 11:46 PM

It should work.  Is this the configuration file of your executable project?  Is this configured on your default configuration file or on a separate? 

I just noticed though the order attribute in <add name="Policy1" order="0"> which I think shouldn't be there as it is not a valid attribute in that element.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Mar 21, 2011 at 11:44 AM

This line of code resolved this issue:

container.AddNewExtension<EnterpriseLibraryCoreExtension>();
Thanks for your attention.

Mar 21, 2011 at 11:54 PM

Right, I should've noticed that before.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 16, 2012 at 1:20 PM

any full sample code about it ?

where I put this line: container.AddNewExtension<EnterpriseLibraryCoreExtension>();
 ??

Jan 16, 2012 at 11:34 PM
Edited Jan 16, 2012 at 11:34 PM

You add the code when you want Unity to resolve Enterprise Library objects.  For example:

 

IUnityContainer container = new UnityContainer();
container.AddNewExtension<EnterpriseLibraryCoreExtension>();
            
container.RegisterType<IService, Service>(
    "",    
    new Interceptor(new InterfaceInterceptor()),
    new InterceptionBehavior<PolicyInjectionBehavior>());

If you are having specific problems, I would recommend creating a new post with the information for your scenario.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com