Title: Error with Enum GCHandleType.Pinned · Issue #174 · pythonnet/pythonnet · GitHub
Open Graph Title: Error with Enum GCHandleType.Pinned · Issue #174 · pythonnet/pythonnet
X Title: Error with Enum GCHandleType.Pinned · Issue #174 · pythonnet/pythonnet
Description: Hello, I try to use the following snippet from this page to turn a byte[] into a numpy array: from ctypes import string_at clr.AddReference("System.Runtime.InteropServices") from System.Runtime.InteropServices import GCHandle, GCHandleTy...
Open Graph Description: Hello, I try to use the following snippet from this page to turn a byte[] into a numpy array: from ctypes import string_at clr.AddReference("System.Runtime.InteropServices") from System.Runtime.Int...
X Description: Hello, I try to use the following snippet from this page to turn a byte[] into a numpy array: from ctypes import string_at clr.AddReference("System.Runtime.InteropServices") from System.R...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/174
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error with Enum GCHandleType.Pinned","articleBody":"Hello,\n\nI try to use the following snippet [from this page](https://mail.python.org/pipermail/pythondotnet/2014-May/001525.html) to turn a `byte[]` into a numpy array:\n\n``` python\nfrom ctypes import string_at\nclr.AddReference(\"System.Runtime.InteropServices\")\nfrom System.Runtime.InteropServices import GCHandle, GCHandleType\n\nhandler = GCHandle.Alloc(CSArray, GCHandleType.Pinned)\ntry:\n pointer = handler.AddrOfPinnedObject().ToInt32()\n dest = np.fromstring(string_at(pointer, len(CSArray))) \nfinally:\n if handler.IsAllocated: handler.Free()\n```\n\nOn this line:\n\n``` python\nhandler = GCHandle.Alloc(CSArray, GCHandleType.Pinned)\n```\n\nI get the following error: `TypeError: No method matches given arguments`\n\nExecuting this code:\n\n``` python\nhandler = GCHandle.Alloc(CSArray)\n```\n\nbrings no error, so I assume that the issue must be from `GCHandleType.Pinned`.\n\nI'm a bit troubled by: \n\n``` python\nprint(type(GCHandleType.Pinned))\n\u003e\u003e\u003eint\nprint(GCHandleType.Pinned)\n\u003e\u003e\u003e3\n```\n\nIs it normal that `enum`are modeled by `int`?\n\nAnyway, I can't get to have my code working...\n","author":{"url":"https://github.com/aPere3","@type":"Person","name":"aPere3"},"datePublished":"2016-03-03T11:00:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/174/pythonnet/issues/174"}
| 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:bda2f2f3-1d20-082e-fff8-a803537f88cb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A72E:36D01B:146A8AF:1C8A880:6970D172 |
| html-safe-nonce | b6be124381e1e9ba396818d1d9310e92ca8c6465eac64b4946957c5fc44e059f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzJFOjM2RDAxQjoxNDZBOEFGOjFDOEE4ODA6Njk3MEQxNzIiLCJ2aXNpdG9yX2lkIjoiODI5OTA5NjMzMDY1NTAyNzU3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 87cb598bfc420cfdcbf2f4684482514b8d3b65a75ec7e749445e5d117760327f |
| hovercard-subject-tag | issue:138145850 |
| 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/174/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3c8318b1a71ee4a59d5e781fb182da094900d4c75f2dfe94ddb2b63ac55ee0a7/pythonnet/pythonnet/issues/174 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3c8318b1a71ee4a59d5e781fb182da094900d4c75f2dfe94ddb2b63ac55ee0a7/pythonnet/pythonnet/issues/174 |
| og:image:alt | Hello, I try to use the following snippet from this page to turn a byte[] into a numpy array: from ctypes import string_at clr.AddReference("System.Runtime.InteropServices") from System.Runtime.Int... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | aPere3 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 034aaee9edccd455c18591b13122193c6e12dc773e8a203be73abe934f3e3a72 |
| 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 | 52d1d534d0b88c64972e852deb460d09b433b8b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width