This is bug #20021 - http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20021
You should be able to declare the ctor public. It shouldn't be an error to do that but you'll get an FxCop warning if you run FxCop. I checked a fix for this in today into the Main branch (which is 2.1). I think that should show up on CodePlex tonight or tomorrow if you're willing to build IronPython from source. If not we'll definitely fix this in 2.0.1 if we don't spin a new build for 2.0 which would also likely include the fix. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:users- > [EMAIL PROTECTED] On Behalf Of Mark Traudt > Sent: Wednesday, December 03, 2008 5:49 PM > To: [email protected] > Subject: [IronPython] Problem inheriting from C# abstract base class > with overloaded constructors > > > If I create an abstract base class in C# that has overloaded > constructors, > and then subclass from this in IronPython, then I am unable to call the > non-default base class constructor from the __new__ method in the > subclass. > If I try, I get the result shown after the code sample. > > Interestingly, if I change the base class to not be abstract and to > have > public constructors (both changes are required) then my IronPython > script > works fine. > > Is this a bug? If not, then am I doing something wrong, or is this not > supported for some reason? > > I reproduced this with IronPython-1.1.2 and IronPython-2.0B5. > > > *** OneOff.cs *** > > namespace Test > { > public abstract class Foo > { > protected Foo() > {} > > protected Foo(int a) > { > a_ = a; > } > > public override string ToString() > { > return "Foo: " + a_; > } > > private int a_; > } > } > > > *** OneOff.py *** > > import clr > clr.AddReferenceToFile("OneOff.dll") > from Test import * > > class Bar(Foo): > def __new__ (cls, a=0): > return Foo.__new__(cls, a) > > print Bar() > print Bar(42) > > > *** Results *** > > Traceback (most recent call last): > File C:\dev\OneOff\IronPython\OneOff.py, line 10, in > File C:\dev\OneOff\IronPython\OneOff.py, line 8, in > File , line 0, in DefaultNew##15 > TypeError: default __new__ does not take parameters > > > -- > View this message in context: http://www.nabble.com/Problem-inheriting- > from-C--abstract-base-class-with-overloaded-constructors- > tp20804327p20804327.html > Sent from the IronPython mailing list archive at Nabble.com. > > _______________________________________________ > Users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
