Click here to Skip to main content
15,895,809 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private void captureButton_Click(object sender, EventArgs e)
        {
            #region if capture is not created, create it now
            if (_capture == null)
            {
                try
                {
                    _capture = new Capture();
                }
                catch (NullReferenceException excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
            #endregion

            if (_capture != null)
            {
                if (_captureInProgress)
                {  //stop the capture
                    captureButton.Text = "Start Capture";
                    Application.Idle -= ProcessFrame;
                }
                else
                {
                    //start the capture
                    captureButton.Text = "Stop";
                    Application.Idle += ProcessFrame;
                }

                _captureInProgress = !_captureInProgress;
            }
        }


When I click on captureButton_Click,it threw an unhandled exception like below:
An attempt was made to load a program with an incorrect format. (System.BadImageFormatException)A System.BadImageFormatException was thrown. An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Can anyone please help me out? I'm new to it. Thanks.
I'm using VS 2010 with 64 bits, emgu library.
Posted
Updated 28-Apr-17 3:07am

1 solution

Usually this is related to the difference in 64bit and 32bit DLL builds and processes.

Try compiling to 32bit by changing project properties/Build/Platform Target.
 
Share this answer
 
v3
Comments
Abhinav S 6-May-12 3:42am    
Good point. 5.
Mehdi Gholam 6-May-12 3:44am    
Thanks Abhinav!
(__Aaron__) 6-May-12 8:28am    
Good answer 5
Wendy2012 6-May-12 11:23am    
Hi Medhi Gholam, i change it but the same exception still appears.
Mehdi Gholam 6-May-12 14:43pm    
Make sure all your projects (DLL) and your EXE file are set to 32bit.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900