Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PythonEngine fails to initialize in VSIX extension#2405

Closed Answeredbycpgames
cpgames asked this question inQ&A
Discussion options

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 a VSIX Visual Studio extension.
The Experimental VS Instance initializes pythonnet fine, however deploying an extension causes this crash.
I suspect there may be some threading issues, but am not sure what to look for.

try{    Runtime.PythonDLL = pythonFile.FullName;    PythonEngine.PythonHome = pythonFile.DirectoryName!;    OutputWindowHelper.LogInfo("PythonEngine", "Initializing Python engine.");    PythonEngine.Initialize(); // crash here    PythonEngine.BeginAllowThreads();}catch (Exception ex){    OutputWindowHelper.LogError(ex);}
  • If there was a crash, please include the traceback here.
[INFO] - PythonEngine: Initializing Python engine.[ERROR]: Object reference not set to an instance of an object.[TRACE]:    at Python.Runtime.ClassManager.GetClassInfo(Type type, ClassBase impl)   at Python.Runtime.ClassManager.InitClassBase(Type type, ClassBase impl, ReflectedClrType pyType)   at Python.Runtime.ReflectedClrType.GetOrCreate(Type type)   at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess)   at Python.Runtime.ModuleObject.LoadNames()   at Python.Runtime.ImportHook.UpdateCLRModuleDict()   at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)   at Python.Runtime.PythonEngine.Initialize()   at cpGames.VSA.ToolAPI.<InitializePythonEngineAsync>d__2.MoveNext() in ToolAPI.cs:line 69 // PythonEngine.Initialize(); call
You must be logged in to vote

Why you close my issue?

Here's your fix:

internal static bool ShouldBindEvent(EventInfo ei)        {            var mb = ei.GetAddMethod(true);            if (mb == null)            {                return false;            }            return ShouldBindMethod(mb);        }

Check your nulls, thank me later.

Replies: 2 comments

Comment options

Why you close my issue?

Here's your fix:

internal static bool ShouldBindEvent(EventInfo ei)        {            var mb = ei.GetAddMethod(true);            if (mb == null)            {                return false;            }            return ShouldBindMethod(mb);        }

Check your nulls, thank me later.

You must be logged in to vote
0 replies
Answer selected bycpgames
Comment options

Hello ,

I have the same issue, I am trying to use pythonnet package in a VSIX Visual Studio extension.

image

I am going to apply this fix above made by@cpgames and see if the problem persists.

Do you intend to release this fix in a future version of pythonnet ?

Regards,

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@cpgames@adrctr
Converted from issue

This discussion was converted from issue #2404 on June 23, 2024 07:54.


[8]ページ先頭

©2009-2025 Movatter.jp