Geeks With Blogs
Ben Adler's Development Posting solutions as I find them

I was receiving a system.badimageformatexception when I went to run NUnit test.

The problem was that even though the solution platform was set to ‘Any CPU’, the platform target for the test project was set to 64bit. Setting the platform target to ‘Any CPU’ solved the problem.

 

 

Posted on Friday, May 13, 2011 11:04 AM NUnit | Back to top


Comments on this post: NUnit: system.badimageformatexception

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
This worked for me!
In addition I would like to add that it does not need to be "Any CPU". x86 or x64 work as well as long as the project build target is the same for both the original project as the testproject.
Left by BobCl on Aug 09, 2011 6:10 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Exactly what I needed to know - thanks very much.
Left by Bevan Arps on Dec 17, 2011 3:06 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Thanks. It works
Left by NY on Dec 20, 2011 10:38 PM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Thanks! That worked. Very helpful post.
Left by James on Feb 29, 2012 3:59 PM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Thank you. It helped me also. Library which needs to be tested was built as x86 instead of Any CPU.
Left by Igor on May 02, 2012 8:42 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Also if you use TeamCity to run NUnit, remember to change the .NET Runtime version in the Build Step configuration from v2.0 to v4.0
(I have Any CPU projects developed in 32 -bit OS, the TC build machine is 64bit)

.NET Runtime: Platform: to auto (MSIL)
Version: v2.0 to v4.0
Left by Hannu K. on Aug 06, 2012 7:04 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Thanks, this was very helpful :)
Left by vpalmu on Oct 16, 2012 9:55 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Thanks so much, BobCl, settings the test project to the same as the assembly was what I needed.
Left by Gerry on Nov 19, 2012 2:23 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
Thank's a lot.

BOTH a testproject and main project must be set as ANY CPU
Left by Roman Vitruk on Dec 18, 2012 5:19 AM

# re: NUnit: system.badimageformatexception
Requesting Gravatar...
If your platform target must be x86 and you're encountering this problem on a 64 bit machine, go here:

http://www.nunit.org/index.php?p=nunit-gui&r=2.4.2

And check out the section: NUnit on 64-Bit Platforms...in a nutshell run nunit-x86.exe (instead of changing your code).
Left by Kyle on Apr 12, 2013 12:19 PM

Your comment:
 (will show your gravatar)


Copyright © BenAdler | Powered by: GeeksWithBlogs.net