Title: PythonEngine fails to initialize in VSIX extension · pythonnet/pythonnet · Discussion #2405 · GitHub
Open Graph Title: PythonEngine fails to initialize in VSIX extension · pythonnet/pythonnet · Discussion #2405
X Title: PythonEngine fails to initialize in VSIX extension · pythonnet/pythonnet · Discussion #2405
Description: PythonEngine fails to initialize in VSIX extension
Open Graph Description: Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in...
X Description: Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in...
Opengraph URL: https://github.com/pythonnet/pythonnet/discussions/2405
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"PythonEngine fails to initialize in VSIX extension","text":"Environment
\n\n- Pythonnet version: 3.0.3, 3.1.0
\n- Python version: 3.09
\n- Operating System: Win11
\n- .NET Runtime: 4.8
\n
\nDetails
\n\n- Describe what you were trying to get done.
\n
\nI am trying to use pythonnet package in a VSIX Visual Studio extension.
\nThe Experimental VS Instance initializes pythonnet fine, however deploying an extension causes this crash.
\nI suspect there may be some threading issues, but am not sure what to look for.
\n\n- What commands did you run to trigger this issue? If you can provide a
\nMinimal, Complete, and Verifiable example
\nthis will help us understand the issue. \n
\ntry\n{\n Runtime.PythonDLL = pythonFile.FullName;\n PythonEngine.PythonHome = pythonFile.DirectoryName!;\n OutputWindowHelper.LogInfo(\"PythonEngine\", \"Initializing Python engine.\");\n PythonEngine.Initialize(); // crash here\n PythonEngine.BeginAllowThreads();\n}\ncatch (Exception ex)\n{\n OutputWindowHelper.LogError(ex);\n}\n
\n\n- If there was a crash, please include the traceback here.
\n
\n[INFO] - PythonEngine: Initializing Python engine.\n[ERROR]: Object reference not set to an instance of an object.\n[TRACE]: at Python.Runtime.ClassManager.GetClassInfo(Type type, ClassBase impl)\n at Python.Runtime.ClassManager.InitClassBase(Type type, ClassBase impl, ReflectedClrType pyType)\n at Python.Runtime.ReflectedClrType.GetOrCreate(Type type)\n at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess)\n at Python.Runtime.ModuleObject.LoadNames()\n at Python.Runtime.ImportHook.UpdateCLRModuleDict()\n at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)\n at Python.Runtime.PythonEngine.Initialize()\n at cpGames.VSA.ToolAPI.<InitializePythonEngineAsync>d__2.MoveNext() in ToolAPI.cs:line 69 // PythonEngine.Initialize(); call\n
","upvoteCount":2,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"Why you close my issue?
\nHere's your fix:
\ninternal static bool ShouldBindEvent(EventInfo ei)\n {\n var mb = ei.GetAddMethod(true);\n if (mb == null)\n {\n return false;\n }\n return ShouldBindMethod(mb);\n }\n
\nCheck your nulls, thank me later.
","upvoteCount":2,"url":"https://github.com/pythonnet/pythonnet/discussions/2405#discussioncomment-9850990"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:be287e78-ec10-6705-3698-3fe3e534c02b |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | E41E:1298D8:30B12B7:41A0772:69706585 |
| html-safe-nonce | e8e045c2f469c5e5eb04a3760c720b7f6a7468548f31e8de167ab31a689690f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDFFOjEyOThEODozMEIxMkI3OjQxQTA3NzI6Njk3MDY1ODUiLCJ2aXNpdG9yX2lkIjoiNDUxNjY5NTczMDQ5MDE3NzMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2571b9e65ba1d5831f328f9538d7b37b4ed9352a337a808ee2fe79a03be19715 |
| hovercard-subject-tag | discussion:6850833 |
| github-keyboard-shortcuts | repository,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/Voltron::DiscussionsFragmentsController/show/pythonnet/pythonnet/2405/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/98aa3e9cf610d15ebcc4f7616bd33ff843d8a23985fc573e5820efdc8ae43e9f/pythonnet/pythonnet/discussions/2405 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/98aa3e9cf610d15ebcc4f7616bd33ff843d8a23985fc573e5820efdc8ae43e9f/pythonnet/pythonnet/discussions/2405 |
| og:image:alt | Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| 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