Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using Visual Studio 2012 / C# with nUnit test, and get System.AccessViolationException on simple test...

When I launch the "Execute Test" option, the test returns OK.
When I launch the "Debug Test" option, I get System.AccessViolationException.

I think something in my config is not good. I'm pretty sure the source is good and has no hidden bug.

Any help will help.

Here is the code :

Class1.cs
using System;

namespace ClassLibrary1
{
    public class Class1
    {
        public String test = "1";
        public Class1()
        {
        }

        public void Test()
        {
            test = "2";
        }
    }
}


UnitTest1.cs
using ClassLibrary1;
using NUnit.Framework;


namespace UnitTestProject1
{
    [TestFixture]
    public class UnitTest1
    {
        [Test]
        public void TestMethod1()
        {
            Class1 classe = new Class1();
            Assert.AreEqual(classe.test, "1");
            classe.Test();
            Assert.AreEqual(classe.test, "2");
        }
    }
}


What I have tried:

Try to reinstall VS2012 + nUnit with no success.
Posted
Updated 19-Jul-17 21:00pm

1 solution

It looks like this VS bug: Weird Access Violation Exception

Reported here: https://connect.microsoft.com/VisualStudio/feedback/details/911564/access-violation-exception-in-vs-hosting-process-when-debugging-application

And assumingly fixed in this .NET release: http://www.microsoft.com/en-us/download/details.aspx?id=42642
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900