System.Badimageformatexception: Could Not Load File or Assembly

System.BadImageFormatException: Could not load file or assembly

It seems that you are using the 64-bit version of the tool to install a 32-bit/x86 architecture application. Look for the 32-bit version of the tool here:

C:\Windows\Microsoft.NET\Framework\v4.0.30319

and it should install your 32-bit application just fine.

BadImageFormatException Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format

As mentioned already it is due to wrong architecture either
a) Using x64 assembly with Windows x86
b) Using x86 assembly with x64 process or viceversa

For best results, ensure all .NET assemblies are built with "Any CPU", and same .NET profile (ie all using .NET Core, or Client Profile or Full .NET).

...or one dependency not being found at all, Enable Fusion Log to tell where is looking to gather the assemblies:

See How to enable assembly bind failure logging (Fusion) in .NET
and
http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx

UPDATE: Given the error code 0x8007000b I am pretty sure is an architecture mismatch:
a) The dll may be Full .NET code, but not compiled with AnyCPU
b) The dll may be native code, and then you need a matching architecture (plus some calling its code using PInvoke)
c) The dll may be C++ CLI (mix of native/.NET code, again with wrong architecture).
d) The dll may be corrupt.

You may need to contact the 3rd party provider for support.
Also, this link mentions it could be a mismatch of .NET version.

Anyway, looks like the problem is narrowed.

Also if the DLL is partly native, it may need the MSVC runtime (as this question's answers mentions, Using 32-bit dll on 64-bit system shows 0x8007000B Error)

In that case the problem would be a dependency of dcasdk not being found.
You can check which Dependency Walker, see http://www.dependencywalker.com/
(it also has a profile mode where you profile an exe, and see the call to open a dll which failed at runtime).

System.BadImageFormatException: Could not load file or assembly (from installutil.exe)

Make sure the newest Framework (the one you compiled your app with) is first in the PATH. That solved the problem for me. (Found on a forum)

System.BadImageFormatException: 'Could not load file or assembly

The problem was solved.
I should not use the 64-bit version, I should use the 32-bit version.

C# CLR Excecption BadImageFormatException: Could not load file or assembly

You should change Platform target to "X86" here
Sample Image



Related Topics



Leave a reply



Submit