Error: An unhandled exception of type 'System.BadImageFormatException' occurred in System.Windows.Forms.dll
Asked Answered
R

2

10

New error popped up when I created new build configuration  for x86Target not setting to x86I am trying to capture the frames from a video stream and I am trying to use AForge library for that purpose. But when i try to call any of the API's of the library from my project it gives me the above error.

My research shows that it could be due to using 32 bit windows dll on x64 or vice-versa.But i have not been able to find out any AForge library package for 64 bit windows. I am using x64 windows7. Any links or suggestions that can help me to resolve this error will be really appreciated.enter image description here

Rouble answered 12/5, 2015 at 6:20 Comment(6)
Set your project to target x86 instead of AnyCPU.Bogor
@Brendan Green: I am still getting the same error..Rouble
Is your AForge library 32-bit or 64-bit?Bogor
@Brendan Green: I have tried setting target x86 nad build and rebuild it but at the top it still shows AnyCpu as shown in Above screen shot ..I beleive its 64 bit because when i create a new project from scratch and use it there it works just fine...Rouble
The "top" isn't your target platform, it's the name of your build configuration.. Since your library is x64, change your target platform to x64 instead of x86. You should create a new build configuration for x64 to avoid confusion and make changing target platforms easierEdict
@ Panagiotis Kanavos: I have tried both x86 and x64 ..it didn't work...however when i created a new build config as u suggested it pops up a new error as shown in above picture..What should I do?Rouble
R
4

I would like to thank every one for their contruibution..Following steps solved the issue...This link worked

Created a new solution Added the existing projects Just place the appropriate config file near your exe, and fill it with:

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Might help someone as well..

Rouble answered 12/5, 2015 at 8:24 Comment(0)
E
8

I have changed platform target to x86 and my program Successfully run on x86 and x64 systems. Thank you all for help. I have changed platform target to x86 and my program Successfully run on x86 and x64 systems More details. I have 5 project in the solution. Two project using framework 2.0 it is a base classes and other project and exe project using framework 4.0. Something change in the base project and solution good build but not running. Last release the project was two years old. I made new release but it is run. I was happy do fast fix with change project target on x86. But we are not found the cause this trouble

Earthenware answered 7/12, 2016 at 9:7 Comment(0)
R
4

I would like to thank every one for their contruibution..Following steps solved the issue...This link worked

Created a new solution Added the existing projects Just place the appropriate config file near your exe, and fill it with:

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

Might help someone as well..

Rouble answered 12/5, 2015 at 8:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.