Title: Incorrect overloaded method got precedence while invoking .Net functions/methods from Python · Issue #1211 · pythonnet/pythonnet · GitHub
Open Graph Title: Incorrect overloaded method got precedence while invoking .Net functions/methods from Python · Issue #1211 · pythonnet/pythonnet
X Title: Incorrect overloaded method got precedence while invoking .Net functions/methods from Python · Issue #1211 · pythonnet/pythonnet
Description: Environment Pythonnet version: 2.5.1 Python version: 3.8.2 Operating System: Windows 10 Details In PythonNet 2.5.1, I found correct/appropriate overloaded .Net methods are not invoked from Python while executing .Net code statements for ...
Open Graph Description: Environment Pythonnet version: 2.5.1 Python version: 3.8.2 Operating System: Windows 10 Details In PythonNet 2.5.1, I found correct/appropriate overloaded .Net methods are not invoked from Python w...
X Description: Environment Pythonnet version: 2.5.1 Python version: 3.8.2 Operating System: Windows 10 Details In PythonNet 2.5.1, I found correct/appropriate overloaded .Net methods are not invoked from Python w...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/1211
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect overloaded method got precedence while invoking .Net functions/methods from Python","articleBody":"### Environment\r\n\r\n- Pythonnet version: 2.5.1\r\n- Python version: 3.8.2\r\n- Operating System: Windows 10\r\n\r\n### Details\r\nIn PythonNet 2.5.1, I found correct/appropriate overloaded .Net methods are not invoked from Python while executing .Net code statements \r\n\r\nfor example please find the below code throws an error while trying to execute System.Data.DataRowCollection.Add(System.Data.DataRow) method.\r\n\r\nReference: https://docs.microsoft.com/en-us/dotnet/api/system.data.datarowcollection.add?view=netframework-4.8\r\n\r\nCode:\r\n```python\r\n#PYTHON 3.8.x PYTHONNET 2.5.1\r\nimport clr\r\nclr.AddReference(\"System\")\r\nclr.AddReference(\"System.Data\")\r\nimport System\r\nimport System.Data\r\n\r\ndt = System.Data.DataTable()\r\ncol = System.Data.DataColumn()\r\ncol.ColumnName = \"Id\"\r\ncol.DataType = System.Type.GetType(\"System.Int32\")\r\ndt.Columns.Add(col)\r\ndr = dt.NewRow()\r\ndr[\"Id\"] = 10\r\n#Throws error while invoking void System.Data.DataRowCollection.Add(System.Data.DataRow row)\r\ntry:\r\n dt.Rows.Add(dr)\r\nexcept Exception as e:\r\n print(e)\r\n\r\n#Working as expected while invoking System.Data.DataRow Add (params object[] values)\r\ndr = dt.Rows.Add(20)\r\nprint(dr[0])\r\n```\r\n[params_overloaded_function_precedence_issue.py.txt](https://github.com/pythonnet/pythonnet/files/5145942/params_overloaded_function_precedence_issue.py.txt)\r\n\r\n\r\n\r\n\r\nUnable to cast object of type 'System.Data.DataRow' to type 'System.IConvertible'.Couldn't store \u003cSystem.Data.DataRow\u003e in Id Column. Expected type is Int32.\r\n at System.Data.DataColumn.set_Item(Int32 record, Object value)\r\n at System.Data.DataTable.NewRecordFromArray(Object[] value)\r\n at System.Data.DataRowCollection.Add(Object[] values)\r\n\r\n\r\nI could fix this issue in local repo by patching Python.Runtime.MethodBinder.GetPrecedence method, I set lower precedence to overloaded methods with Params array parameter\r\n\r\nPlease have a look and let me know your suggestions\r\n\r\n-Parthasarathy K","author":{"url":"https://github.com/partha-srivi","@type":"Person","name":"partha-srivi"},"datePublished":"2020-08-29T20:18:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1211/pythonnet/issues/1211"}
| 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:18e7c30c-4810-d2e5-f924-1a3c6dc129a0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A1D8:3017E0:902FCE:BE6D46:6971667F |
| html-safe-nonce | 17ea58c734ddef275874c9b538fc99af89a54a70442eba803a23a6ac4d1d5dfd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUQ4OjMwMTdFMDo5MDJGQ0U6QkU2RDQ2OjY5NzE2NjdGIiwidmlzaXRvcl9pZCI6Ijg3NzI2NzQ3MDYyMDU2NjQ4OTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4a1749fdf2ba7961177b396e9d88be78caab91b91a131108b2b798f77e24c134 |
| hovercard-subject-tag | issue:688598064 |
| 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/1211/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1e3687388d1fde851b7dd6d0692a17373884ec5b7cf773e42a6b318762c6d40e/pythonnet/pythonnet/issues/1211 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1e3687388d1fde851b7dd6d0692a17373884ec5b7cf773e42a6b318762c6d40e/pythonnet/pythonnet/issues/1211 |
| og:image:alt | Environment Pythonnet version: 2.5.1 Python version: 3.8.2 Operating System: Windows 10 Details In PythonNet 2.5.1, I found correct/appropriate overloaded .Net methods are not invoked from Python w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | partha-srivi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 873364ab8c3892d45b3a7f6c012702ee84934662b47c9312d99f8b31dd9c2668 |
| 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 | fa6ed180534301da051f8e5cb00f3a1dfab789ec |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width