You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue comes from this StackOverflow question.
I was trying to use a C# DLL which has a class that overrides a non-abstract method of its parent class. Although the new method should be used, pythonnet still calls the parent method. The code for a minimal DLL to reproduce this problem looks like this:
using System;namespaceInheritanceTest{publicclassBaseClass{publicboolTransmit(){thrownew NotImplementedException();}}publicclassInheritedClass:BaseClass{publicnewboolTransmit(){
Console.WriteLine("Success!");returntrue;}}}
In the following python code, BaseClass.Transmit should be called when BaseClass is directly instantiated and InheritedClass.Transmit when InheritedClass is instantiated. However, BaseClass.Transmit is called both times.
## setupimportclrimportosclr.AddReference(os.getcwd() +'\\InheritanceTest.dll')
importInheritanceTest## method testbase_class=InheritanceTest.BaseClass()
base_class.Transmit() # throws a NotImplementedException as expectedinherited_class=InheritanceTest.InheritedClass()
inherited_class.Transmit() # still throws a NotImplementedException, although it should call InheritedClass.Transmit
The text was updated successfully, but these errors were encountered:
@denfromufa It seems to me that #552 is the exact same issue (although worded a little strangely in my opinion, i wasn't able to find it when first researching the problem). #756 fixes #552 too.
Environment
Details
This issue comes from this StackOverflow question.
I was trying to use a C# DLL which has a class that overrides a non-abstract method of its parent class. Although the new method should be used, pythonnet still calls the parent method. The code for a minimal DLL to reproduce this problem looks like this:
Minimal, Complete, and Verifiable example
this will help us understand the issue.
In the following python code,
BaseClass.Transmit
should be called whenBaseClass
is directly instantiated andInheritedClass.Transmit
whenInheritedClass
is instantiated. However,BaseClass.Transmit
is called both times.The text was updated successfully, but these errors were encountered: