NUnit and System.BadImageFormatException

Posted on 2007-08-08
Last Modified: 2013-12-17
I am using NUnit-Gui version 2.2.0 and VS2005.  I created a C# class project.  Here is my code:

using System;
using NUnit.Framework;

namespace NUnitQuickStart
    public class NumbersFixture
        public void AddTwoNumbers()
            int a = 1;
            int b = 2;
            int sum = a + b;
            Assert.AreEqual(3, sum);
This project was built without any error.   I try to debug this project by using NUnit-Gui.  I go to Fileà Open and clicked on NUnitQuickStart.dll.   I got the following error message:
"System.BadImageFormatException". The format of the file "PCM.Brokers.Tests" is invalid

Please help me resolve this problem.
Question by:lina06
    LVL 12

    Expert Comment

    So, you start the NUNit GUI..
    click File / Open Project
    Browse to the bin/debug/ directory under your C# project
    Open the dll, which is the output of your c# project compilation...?

    That's exactly correct. Sounds like the build isn't working or something... Are you _sure_ you're opening the right .dll?

    Try remocing the dll, rebuilding the project, and making sure it gets created again!

    Author Comment

    Yes, several times I removed dll and rebuilt the project.  It gave me the same error.
    LVL 12

    Accepted Solution

    Try getting the latest version. On older versions you had to tweak a config to choose between .net 1 and .net2 - maybe you've not done that?

    What's PCM.Brokers.Tests? Is it you file? Is there more code to your project that you're not showing, or is the posted code the entirity of the project you're trying to Nunit test for the moment?

    Author Comment

    Thank you.
    I downloaded NUnit-Net- and it woks fine for me.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now