XNA Essentials

Game Programming for Xbox 360, PC + Windows Phone

NAVIGATION - SEARCH

Ch. 3 BadImageFormatException

I've read through sources online and in the Errata page for this book, but cannot seem to find the answer. With the Errata page, I downloaded the XNAPerformanceChecker file and tried to add that to my project containing the CD code. I don't understand what I am to do with the downloaded file. Can you provide assistance?

Mr. Peanut - Tuesday, June 29, 2010 @ 3:49 PM

Re: Ch. 3 BadImageFormatException

Sorry for the trouble you are having.


The easiest thing to do is overwrite the XNAPerformanceChecker.csproj from the cd with this file.  Then double click on it and compile it.  The original file that was included  was for the CTP version instead of the final release version.


The downloaded file should simply replace the other file that already exists.  Then double clicking on the .csproj file should open it up inside of Visual Studio / Visual C# Express.  The .sln (solution) file will also load up the project just fine.


Once it is loaded you can hit CTRL+F5 to build it or just hit F5 (or hit the play button) to compile and run the code.


Hope this helps, but if not please let me know and I'll try to do better at explaining it.


Thanks!


Chad

Chad Carter - Tuesday, June 29, 2010 @ 10:48 PM

Re: Ch. 3 BadImageFormatException

Thanks for the quick response! 


Here's what I've tried so far:

I  copied the Ch. 3 project "XNAPerformanceChecker" from the CD to my local Projects directory. With that in place, I found the XNAPerformanceChecker.csproj file and replaced it with the one given in the Errata download. I then tried to compile the project in VS2008, but still come away with an BadImageFormatException. Any idea as to what I'm doing wrong? 


Thanks for the help, by the way, and good book so far too.

Mr. Peanut - Wednesday, June 30, 2010 @ 1:26 AM

Re: Ch. 3 BadImageFormatException

This link has information on the error you are getting:


http://msdn.microsoft.com/en-us/library/system.badimageformatexception.aspx


One common reason is 32/64 bit mixing of assemblies.  I believe if you right click on the Solution and click Rebuild All that you will see it go away.  If that doesn't work then you may just want to manually delete the /bin and /obj folders from the project folders.  This way it has to do a rebuild.


Sorry for the trouble you are having - hopefully this will solve it.


Thanks for the compliment on the book -- hopefully it won't be so painful to get the other examples working for you :)

Chad Carter - Wednesday, June 30, 2010 @ 8:07 AM

Re: Ch. 3 BadImageFormatException

So I'm still having troubles with the Exception. I've tried all of the advice given on this board and others, but with no luck. Seeing as these solutions work for most others, I'm guessing I'm not following them correctly. But my question now is this: Is this example something that will be utilized later on in the book, or is it more of a proof of concept for the chapter? If it's the latter, I would like to simply continue with the rest of the book. But if it is necessary for later examples, then it makes no sense to continue without finding a solution to the problem. Thanks for your help again.

Mr. Peanut - Wednesday, June 30, 2010 @ 12:19 PM

Re: Ch. 3 BadImageFormatException

It is really just concepts and not required for the rest of the book.  You can just skip it.  If you wanted to try it again the only other thing I would suggest is to create a totally new folder and copy the files from the CD and then copy the new .csproj file over it and then open it up and do a Rebuild All.  But if it still doesn't work for you, then you aren't out of much.


I sincerely hope you have better success with the rest of the book.  I'm sorry this project has been such a pain!

Chad Carter - Wednesday, June 30, 2010 @ 2:11 PM

Re: Ch. 3 BadImageFormatException

Hi Folks,


I just ran into the same issue with this example. I'm running Windows 7 64 bit. I had the option of running Visual c# 2010 express with XNA 4.0, but I also had a standard edition of Visual Studio 2008 with XNA 3.2. Made sense being compatible with the book, and it's been a pain running multiple project solutions in Express in the past.


I tried the above fix (compile to x86) but am encountered the same issue. Could this issue be related to the underlying XNA assemblies in 3.2? Maybe 64 bit support only came in on 4.0?


Thanks


Jim


 

Spodgy - Friday, November 19, 2010 @ 5:37 PM