Skip to content

System.BadImageFormatException in Window Form Visual Studio 2017 #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
STREETKILLER007 opened this issue Aug 14, 2018 · 1 comment
Closed

Comments

@STREETKILLER007
Copy link

STREETKILLER007 commented Aug 14, 2018

Environment

  1. Pythonnet version: v2.3.0

11

i downloaded this from "Manage Nuget-Package" in Visual Studio 2017 Community

  1. Python version: Python 3.6.5 (Amaconda 3)

Already pip install pythonnet in the environment.

  1. Operating System: Window 7, 64 bit

  2. Software Used : Microsoft Visual Studio Community 2017

4.1) .net framework : 4

  1. python version from cmd

111

  1. where python from cmd

112

  1. path includes

M:\Anaconda3;M:\Anaconda3\Library\mingww64\bin;M:\Anaconda3\Library\usr\bin;M:\Anaconda3\Library\bin;M:\Anaconda3\Scripts

Details

To do : Trying to implement Python in c# form

Progress :

running this code.

private static void button_Click(object sender, EventArgs e)
{
    using (Py.GIL())   
    {
         dynamic myVisbrain = Py.Import("Visbrain"); 
    }
}

when debug,

from program.cs

Application.Run(new Form1()); // crashes here

error message :

Exception thrown: 'System.BadImageFormatException' in System.Windows.Forms.dll
An unhandled exception of type 'System.BadImageFormatException' occurred in System.Windows.Forms.dll
Could not load file or assembly 'Python.Runtime, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

stack trace :

System.BadImageFormatException
  HResult=0x8007000B
  Message=Could not load file or assembly 'Python.Runtime, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
  Source=WindowsFormsAppJTTH
  StackTrace:
   at WindowsFormsAppJTTH.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Administrator\source\repos\WindowsFormsAppJTTH\WindowsFormsAppJTTH\Form1.cs:line 219
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at WindowsFormsAppJTTH.Program.Main() in C:\Users\Administrator\source\repos\WindowsFormsAppJTTH\WindowsFormsAppJTTH\Program.cs:line 19

Would like to know how to solve this, thank you.

@den-run-ai
Copy link
Contributor

this is duplicate, next time please search the issue tracker and wiki:

#472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants