Share via


Could not load file or assembly X or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Question

Monday, November 8, 2010 6:23 PM

DLL: FlyCapture2Managed.dll to x64

OS: Windows 7 64

I just can not use the dll.

The full error:

System.BadImageFormatException was unhandled
  Message= is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
  Source=CameraAcquisition3Form
  StackTrace:
       at CameraAcquisition3Form.CameraHandler.StartCamera()
       at CameraAcquisition3Form.CameraControl.tsbStart_Click(Object sender, EventArgs e) in D:...\CameraAcquisition3Form\CameraAcquisition3Form\CameraControl.cs:line 24
       at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.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(Int32 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 CameraAcquisition3Form.FrmMain.Main() in D:...\CameraAcquisition3Form\CameraAcquisition3Form\CameraAcquisition3Form\FrmMain.cs:line 19
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

All replies (5)

Wednesday, November 10, 2010 7:40 PM ✅Answered

Well, the problem was with the company that build the dlls !! Amazing.. ¬¬

Thank you !


Monday, November 8, 2010 6:55 PM

You are trying to load a 32bit dll. Try find a 64bit dll instead, or switch to 32bit altogether.

This is an FAQ in the 64bit development forum under the .Net development category.

The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP


Monday, November 8, 2010 7:01 PM

But Im loading a 64 bits dll, at least it is what the dll developers says. The path is: C:\Program Files\Point Grey Research\FlyCapture2\bin64

Ive tried to switch the Platform target to x64, x86, Any CPU, Multi-plataform.

When I change it to x86 I get this error:

Could not load file or assembly 'FlyCapture2Managed, Version=1.0.3918.21401, Culture=neutral, PublicKeyToken=76c6583b4a4585f4' or one of its dependencies. An attempt was made to load a program with an incorrect format.

 


Monday, November 8, 2010 7:16 PM | 1 vote

If you load a 64bit dll your process needs to be 64bit, so x86 is the wrong configuration, or you are loading from a wrong folder (does the dll come with a 32bit version that you can load in x86 builds?)

 

The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP


Monday, November 8, 2010 7:53 PM

I was able to run with the x86 dlls nad changing the Platform target to x86.

I could not use the x64 dlls..