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 a netstandard2.0
library. When I try to derive from such a class in Python, it throws a TypeError
during class object creation.
Below is a basic example.
.NET library code:
namespace TestLib
{
public abstract class TestClass
{
public string Foo()
{
return "Foo";
}
protected abstract string Bar();
}
}
Python code:
from pathlib import Path
import clr
clr.AddReference(str(Path(__file__).parent / 'TestLib.dll'))
from TestLib import TestClass
class SubTestClass(TestClass):
__namespace__ = 'CrlTest'
def Bar(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