Instantiating object with overloaded constructors with policy injection

Topics: Policy Injection Application Block
Aug 13, 2009 at 11:32 PM

Hello,

I have a simple class as follows:

public class MyClass : MarshalByRefObject
{
   public MyClass(string key, bool retval)
   {
   }

   public MyClass(bool key, bool retval)
   {
   }

   public MyClass()
   {
   }
}

I wanted to instantiate an object of MyClass with policy injection block. So I write in the console:

MyClass myobj = PolicyInjection.Create<MyClass>("Some Value", false);

But it gives an error: The type MyClass has multiple constructors of length 2. Unable to disambiguate.

Am I doing something wrong here? Any help will be much appreciated.

Aug 14, 2009 at 1:50 AM

I believe this is a bug.  What version of entlib are you using? I tried it on 4.1 and got the same error.  I used 3.1 and was able to successfully create the object.  Most likely, the problem is caused by the incorporation of the unity code.  I'll be creating an item in the issue tracker if this hasn't been logged before.

 

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

Aug 14, 2009 at 2:35 AM

I am also using 4.1. Thanks Sarah.

Aug 14, 2009 at 3:05 AM

Here is the link to the work item i created - http://entlib.codeplex.com/WorkItem/View.aspx?WorkItemId=24325.

 

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