Title: Derived class in Python not being called by C# · Issue #1107 · pythonnet/pythonnet · GitHub
Open Graph Title: Derived class in Python not being called by C# · Issue #1107 · pythonnet/pythonnet
X Title: Derived class in Python not being called by C# · Issue #1107 · pythonnet/pythonnet
Description: Hello - this is my first post so apologies if this is the wrong forum. I'm trying to define a base class in C# and derive from that class in python / pythonnet. The C# class is very basic: public class Order { public string symbol; publi...
Open Graph Description: Hello - this is my first post so apologies if this is the wrong forum. I'm trying to define a base class in C# and derive from that class in python / pythonnet. The C# class is very basic: public c...
X Description: Hello - this is my first post so apologies if this is the wrong forum. I'm trying to define a base class in C# and derive from that class in python / pythonnet. The C# class is very basic: publ...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1107
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Derived class in Python not being called by C#","articleBody":"Hello - this is my first post so apologies if this is the wrong forum.\r\n\r\nI'm trying to define a base class in C# and derive from that class in python / pythonnet. The C# class is very basic:\r\n\r\n```csharp\r\n public class Order\r\n {\r\n public string symbol;\r\n\r\n public virtual void Evaluate( Bar b )\r\n {\r\n Console.WriteLine( \"from Order.Evaluate() - hello!\" );\r\n }\r\n }\r\n```\r\n\r\nIn python I have the specific order class defined as:\r\n\r\n```python\r\nclass LimitOrder(Order):\r\n\r\n def __init__(self):\r\n self.symbol = \"SQ\"\r\n\r\n\r\n def Evaluate( self, bar ):\r\n print( \"LimitOrder.Evaluate() - yay python!\" )\r\n```\r\n\r\nIn C# I have an OMS class with a method: `public void AddOrder( Order order )`\r\n\r\nWhen I pass in `LimitOrder` and call a method in the OMS that calls `Evaluate`, the `Order` class `Evaluate` method is called instead of the `LimitOrder.Evaluate` method.\r\n\r\n\r\nI'm using python 3.6.7 and VS 2019 / .NET 4.7.2\r\n\r\nIn searching for this I'm only seeing 1 instance of a similar question being asked but no solid response. The `Evaluate()` method (and entire `Order` class for that matter) can be abstract but when I try that I get an error creating the `LimitOrder` object saying I can't create an abstract class.\r\n\r\nAny help would be appreciated. Thanks in advance.","author":{"url":"https://github.com/jeffzi19","@type":"Person","name":"jeffzi19"},"datePublished":"2020-04-08T16:14:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/1107/pythonnet/issues/1107"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3fc4409f-9fad-1974-f7c7-cc3db4159f60 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BE2:6834D:2200ED8:2D6BC02:69705F73 |
| html-safe-nonce | 4cfe50eaf07695c2b080d2505a9ae5ac67b00b823ea6c60335e1034bd27e21d7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkUyOjY4MzREOjIyMDBFRDg6MkQ2QkMwMjo2OTcwNUY3MyIsInZpc2l0b3JfaWQiOiIxMzIzNjgxMDMwODc4NTUxOTIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b63fc837efd320a87739445e13a718fb29e0de641738c081d11c90ebce551407 |
| hovercard-subject-tag | issue:596697152 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/1107/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a9df3842611b44c23302b2629f5da45e56e364a2f78660d77970e636a920e75d/pythonnet/pythonnet/issues/1107 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a9df3842611b44c23302b2629f5da45e56e364a2f78660d77970e636a920e75d/pythonnet/pythonnet/issues/1107 |
| og:image:alt | Hello - this is my first post so apologies if this is the wrong forum. I'm trying to define a base class in C# and derive from that class in python / pythonnet. The C# class is very basic: public c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jeffzi19 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width