3

I am not very experienced. Just trying to make some changes to source code that someone else wrote.

I had to add a reference to a .dll to get it to work in "Release" mode. However when I try to get it to work in Debug, it does not work. (assembly reference not loaded).

Help?

brizz
  • 271
  • 1
  • 6
  • 17
  • You need to describe what does not work means, are you getting errors if so what are they? – Mark Hall Mar 19 '14 at 01:41
  • getting error that says the assembly reference is not loaded. It is chillkat.dll – brizz Mar 19 '14 at 01:48
  • specifically: An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll Additional information: Could not load file or assembly 'ChilkatDotNet2, Version=9.0.8.0, Culture=neutral, PublicKeyToken=eb5fc1fc52ef09bd' or one of its dependencies. An attempt was made to load a program with an incorrect format. – brizz Mar 19 '14 at 01:57

3 Answers3

2

It looks like the Chillkat dot net is a actually a mixed mode assembly and it's quiet possible that you need to have the appropriate c runtime as well. This exception and a way to fix this is documented here

Hope this helps.

Soundararajan
  • 2,000
  • 21
  • 23
0

Typically I get this error when the executable is x86 and the dll it's referencing is x64. Check your build configurations to make sure it's targeting the correct platform.

In VS2013 go to Build -> Configuration Manager. There should be a drop down in the top left of the new window which contains the different build modes. Compare Debug to Release.

0

BadImageFormatException is one exception thrown from the execution engine when you are trying to load one assembly compiled for a specific platform in another platform.

Example A

- project A, compiled as X86
- project B, compiled as X86
- executable, compiled in X86

all work fine in x86 machine and x64 operating system

Example B

- project A, compiled as X86
- project B, compiled as X86
- executable, compiled in AnyCPU

all work fine in x86 operating system this throw exception in x64 OS (executable is in AnyCPU so it's run on x64 engine, so can't load x86 dll's)

Example C

- project A, compiled as AnyCPU
- project B, compiled as x86
- executable, compiled in AnyCPU

all work fine in x86 operating system this throw exception in x64 OS (executable is in AnyCPU so it's run on x64 engine, so can't load x86 dll's)

Example D

- project A, compiled as AnyCPU
- project B, compiled as x86
- executable, compiled in x86 

all work fine in x86 operating system all work fine in x64 operating system the exe is compiled specifically for x86 platform, so also in x64 machine run under x86 mode.

Conclusion

Visual studio run projects in OS configuration, so in debug mode if you don't have a specific x86 configuration for starting project and try to execute an x86 referenced dll it will fail