- Notifications
You must be signed in to change notification settings - Fork749
Open
Description
Environment
- Python.NET version: 3.0.5
- Tested on three configurations:
- Windows 10, Python 3.12.4, .NET Framework
- Windows 10, Python 3.12.4, .NET 9.0.201
- Debian 12, Python 3.11.2, .NET 8.0.407
Details
I have an abstract .NET class, which has abstract methods to override within anetstandard2.0
library. When I try to derive from such a class in Python, it throws aTypeError
during class object creation.
Below is a basic example.
.NET library code:
namespaceTestLib{publicabstractclassTestClass{publicstringFoo(){return"Foo";}protectedabstractstringBar();}}
Python code:
frompathlibimportPathimportclrclr.AddReference(str(Path(__file__).parent/'TestLib.dll'))fromTestLibimportTestClassclassSubTestClass(TestClass):__namespace__='CrlTest'defBar(self):return'Bar'if__name__=='__main__':stc=SubTestClass()print('Foo() -> '+stc.Foo())print('Bar() -> '+stc.Bar())
Python script output:
Traceback (most recent call last): File "<redacted>\crl_test.py", line 10, in <module> class SubTestClass(TestClass):TypeError: Method 'Bar' in type 'CrlTest.SubTestClass' from assembly 'Python.Runtime.Dynamic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Metadata
Metadata
Assignees
Labels
No labels