Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PInvokeStackImbalance #485

Closed
Closed
@DeclanHoare

Description

@DeclanHoare

Environment

  • Pythonnet version: pythonnet_py35_dotnet v2.3.0 (from NuGet)
  • Python version: Python 3.5.3
  • Operating System: Windows 7 x86_64

Details

  • When I try to intialise the interpreter, I get this message:
Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'Python.Runtime!Python.Runtime.Runtime::Py_SetPythonHome' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.'

The code I'm using is

PythonEngine.PythonHome = pypath;
PythonEngine.ProgramName = "PythonAPI";
PythonEngine.Initialize();
pylock = PythonEngine.AcquireLock();
AppDomain.CurrentDomain.ProcessExit += (o, a) => { PythonEngine.ReleaseLock(pylock); };
PythonEngine.Exec(Properties.Resources.PythonAPI);

and the exception occurs on the first line. pypath points to a directory containing the entire contents of the "Windows x86 embeddable zip file" of Python 3.5.3 on python.org.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions