5

I have just upgraded a solution previously running in VS2008 on .NET 3.5 to VS2015 running on .NET 4.6.

Some information about the project

  1. The solution only has one project and it is a Unit Test Project and simply creates 'AVTest.dll` which we load into NUnit to perform some functional tests on some hardware.
  2. We do not run it directly, we open NUnit.exe through the start external program debug event. we load the .dll produced by the c# build and NUnit is able to run a series of tests. By running NUnit this way we have in the past been able to debug the routines in the unit test.
  3. NUnit version is 2.5.10 which uses .NET 2.0 (given that we were running and breaking with .NET 3.5 seems like this probably isnt it). Also i upgraded o The latest stable version of NUnit (2.6.4 .NET 3.5) and no change.
  4. We don't have a startup project - everything runs through NUnit.

Everything builds and runs correctly however i get the following error when trying to set breakpoints:

The breakpoint will not currently be hit. No symbols have been loaded for this document.

When i switch back to .NET 3.5 i am able to set breakpoints in the code. The fact that i can do this makes me think i am missing somerthing simple about the .NET version since i am not so familiar with c#.

I am aware of this question and have tried all of the things from the question itself and the first page of answers.

Has there been any developments on how to check why there have been no loaded symbols?

A New Development

I am able to debug just fine when i attach to the Nunit test that is already running. I am not sure why it isnt attached after running (through start external program) or why this works in 3.5 and not 4.6, but it can be debugged ...

Community
  • 1
  • 1
Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175
  • is this for winforms or WebForms..? try doing a clean on the entire solution then rebuild and hit `F10` to start to see if it hits any break points.. are you getting any errors does the app shut down..? or just opens and that's it..? – MethodMan Oct 09 '15 at 00:34
  • 1
    So when you attach to process, what code type are you debugging? – DeanOC Oct 09 '15 at 00:35
  • @ben What is the **project type**? Class library? _"The project is not an app or web project. It creats a .dll to use with NUnit"_ - even "web projects" create a **.dll**. What version of nUnit? How are you running your code? How many projects in the solution? After upgrade it may have changed the _startup project_ –  Oct 09 '15 at 00:37
  • @Roy I have answered your questions to the best of my ability in the latest edit. If you want me to clarify further i can look into anything. – Fantastic Mr Fox Oct 09 '15 at 00:50
  • Ben, thank-you for the extra info. I just did a test with nUnit 2.6.4 and a .NET 4.6 class library (with nUnit text fixtures) and it worked fine. Not sure what the problem is sadly –  Oct 09 '15 at 01:08
  • @Roy Yep, i am also able to create a project from scratch and it works. I feel like its probably to do with the VS + .NET combined upgrade. Thinking about nuking the project and building from scratch, but its really big so that is a bit of a last resort. Keep at it with ideas, willing to try anything. – Fantastic Mr Fox Oct 09 '15 at 01:16
  • I see you are using the external GUI runner and you mentioned it uses .NET 2. [Yes that seems to be the case](http://www.nunit.org/index.php?p=installation&r=2.6.4). They also say _"[although tests may be executed under other versions using a separate process](http://www.nunit.org/index.php?p=installation&r=2.6.4)"_. Would that help? Maybe there is a .config file to edit? I remember once I had to edit the config file once for something else (don't remember link sadly) –  Oct 09 '15 at 01:22
  • As per DeanOC's comment earlier, when you attach the debugger, you need to choose what code type(s) to attach. "Managed (v3.5, v3.0, v2.0)" will not catch your breakpoints, you need to attach the "Managed (v4.5, v4.0)" code type – gigaplex Oct 09 '15 at 05:56
  • @gigaplex how do I change the *Managed Code Type*? I cannot find any option for that. – Fantastic Mr Fox Oct 09 '15 at 15:18
  • When attaching to an already running process, there's a button to configure the code type. When launching the process with the debugger already attached via Visual Studio, I'm not sure if you can specify which .NET mode to attach as. I believe it autodetects based on the assembly you start with. I'd suggest launching without the debugger attached, and attach manually after the fact. – gigaplex Oct 12 '15 at 01:09

1 Answers1

0

This turned out to be a simple problem with NUnit rather than Visual studio. Essentially you need to add this to your NUnit configuration file before the <runtime\> section:

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>

This file is usually located here:

C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-x86.exe.config

Credit for this answer comes from here.

Community
  • 1
  • 1
Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175