0

I'm working on Visual Studio, on a C# .NET project.

I'm trying to use the MatroxImagingLibrary, so I downloaded it from Nuget but it doesn't worked. An exception is thrown : "System.BadImageFormatException" in Matrox.MatroxImagingLibrary.

The exception is thrown when this line is called :

MIL.MappAllocDefault(MIL.M_DEFAULT, ref MilApplication, ref MilSystem, MIL.M_NULL, ref MilDigitizer, MIL.M_NULL);

This is actually the first line using a MIL method, so the problem doesn't come from the code. When I use the debugger, it tells me this :

"An attempt was made to load a program with an incorrect format". I know that this exception appear when there is a problem between x32/x64 files.

I tried all the solutions that I found but none of them where useful for my problem (changing the target CPU, put the mil.dll inside the same folder that the .exe, etc...)

Thank you if you take time to read my problem and I hope someone can help me, I'm stuck in my school project :(

Best regards, Leo

LeoH
  • 13
  • 3

2 Answers2

0

BadImageFormatException can be thrown for a lot of reasons. You can find more details here.

From this question I gather that it is indeed a .NET assembly, so my best guess would be that the .NET version you are using is incompatible to whatever that assembly was compiled in.

This answer should help you to determine which .NET version the library was compiled for.

Once you have that answer, switching your project to that .NET version should fix your error.

Steffen Winkler
  • 2,805
  • 2
  • 35
  • 58
0

Thank you for your answer,

I'll see if your solution can solved my issue. Currently I'm not working on my project, but I'll come back to you when I would have tested.

Best regards, Leo.

LeoH
  • 13
  • 3