Reputation: 2606
I am running a program, which as of now builds fine with no errors or warnings, and I am coming across two run time exceptions in mscorlib.dll.
I get a TypeInitializationException & BadImageFormatException, and the details of the messages are:
System.TypeInitializationException occurred Message: A first chance exception of type 'System.TypeInitializationException' occurred in mscorlib.dll Additional information: The type initializer for 'Service.Program' threw an exception.
And
System.BadImageFormatException occurred Message: A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll Additional information: Could not load file or assembly 'ServiceFrameworkAPI, Version=1.0.0.668, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I've fiddled with the target processors to no success, my target for my project is x86 currently which I had thought to be the way to go after reading some other answers on stack overflow. I checked to break when the exception is hit, but when I see a notification about the run time exception, I am shown a tab with a screen that says "Source Not Available". The exception is thrown immediately before the program enters main.
It also may be worth noting that my solution includes a Managed C++ project, which I think may have something to do with that based on other SO questions. I have read around SO already but I won't be offended if you point me to any other answers, .NET is brand new to me so I may have missed something important. Thanks for any help!
Upvotes: 0
Views: 572
Reputation: 2606
For clarity's sake if anyone ever comes across this question, I'll answer how I fixed.
It turns out I was just using references that weren't the ones I needed (although had identical names). I ended up including some projects in my solution that corresponded to the references and just referenced the projects instead of assemblies and everything worked great.
Upvotes: 0
Reputation: 518
In application you are runnint - try to mark assembly: "ServiceFrameworkAPI" with option: Copy Local = True
Upvotes: 0