Adding NUnit 2.6.1 reference Visual Studio 2012

10,480

Solution 1

I have the same problem for 3 to 4 times when I installed it from NUGet. I resolved it by uninstall and reinstall it from NUGet.

Solution 2

Add the NUnit Reference through NUGet.

The link provides guidance for VS2010, but it's pretty much the same in VS2012.

Share:
10,480
Jean Carlos Suárez Marranzini
Author by

Jean Carlos Suárez Marranzini

Cyber security Adviser from Dominican Republic. Trying to find my .PATH.

Updated on June 04, 2022

Comments

  • Jean Carlos Suárez Marranzini
    Jean Carlos Suárez Marranzini almost 2 years

    I'm using Visual Studio 2012, and I've downloaded NUnit 2.6.1 to run Unit Tests on the code. I've added the reference to nunit.framework in the project of the solution where I'll be needing it.

    The problem is, for some reason when I try to include the namespace it doesn't work. It looks like this:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Threading.Tasks;
    using NUnit.Framework;  //This is not working here
    
    namespace SomeNamespace
    {
        [TestFixture]  //This is not recognized..
        public class SomeClassTest
        {
            [Test]  //Neither recognized..
            public void SomeMethodTest()
            {
                //Ok some implementation goes here..
            }
        }
    }
    

    Any ideas on why it's not working? Thanks in advance!

    PS: I'm using ReSharper as an extension for VS2012... Can this be the source of the problem?

    EDIT: I've tried to install it several times using NUGet, but I get the same error when NUGet finishes installing:

    Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))
    Successfully uninstalled 'NUnit 2.6.1'.
    Install failed. Rolling back...
    Failed to add reference to 'nunit.framework'.
    

    It makes some sort of rollback? I was reading and people say something about the GAC and adding references by hand. I don't know much about this, but could be useful to answer the question.

    • Simon Whitehead
      Simon Whitehead over 11 years
      Possibly target framework related. Check NUnit 2.6.1's target framework and apply that to your solution. Otherwise, get the NUnit distro that targets your specific .NET framework version.
    • spamguy
      spamguy over 11 years
      Definitely not ReSharper related. I don't have it installed but am still having your exact problem.
  • Jean Carlos Suárez Marranzini
    Jean Carlos Suárez Marranzini over 11 years
    I just tried this, but I get this error: Successfully installed 'NUnit 2.6.1'. Error al cargar la biblioteca de tipo/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)) Successfully uninstalled 'NUnit 2.6.1'. Install failed. Rolling back... Failed to add reference to 'nunit.framework'. (Where it says "Error al cargar la biblioteca de tipo" in english it means "Error loading library of type").
  • Jean Carlos Suárez Marranzini
    Jean Carlos Suárez Marranzini over 11 years
    Just tried it, uninstalled all NUnits I had, re-installed NUGet and tried to download NUnit via NUGet... Got same error I wrote in a comment in the first answer... Any other idea?