Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot debug tests using Resharper - Cannot Launch Debugger

Tags:

c#

tdd

resharper

I'm not able to debug my tests using Resharper-Debug option in my project. I have seen this issue raised by lots of people, but has't come across a solid suggestion which solves my issue. The strange thing is that, if I create a sample project and write a simple unit test, I'm able to debug it without any issues.However when I try to do this in my current project, it simply throws a dialog box saying "Cannot Launch Debugger".I have checked this with my peers, and they does't face this issue :(

Also I don't have any issues while running the test.

It's an XP machine and following is the version of resharper:

JetBrains ReSharper 5.1 C# Edition
Build 5.1.1753.4 on 2010-10-15T15:51:30

Licensed to: XXXXXXX
Plugins: none.
Visual Studio 9.0.21022.8.

Copyright © 2003–2011 JetBrains s.r.o.. All rights reserved.

Thanks, -M

like image 424
Mike Avatar asked Jan 12 '11 13:01

Mike


3 Answers

I occasionally encounter a test that can't be launched with the Resharper debug icon (due to mock objects or 32 vs 64 bit dlls). A solution that works for me is to add an explicit call to launch the debugger in the test

Debugger.Launch();

Then just run the test as normal. When code execution hits that line you get a security popup (pick yes)

alt text

then a visual studio choice popup (pick your currently running visual studio).

alt text

You'll be dropped into your code in debug mode at the location where you added the Debugger.Launch() line.

like image 158
Handcraftsman Avatar answered Oct 21 '22 15:10

Handcraftsman


Possibly of use to someone stumbling here, specifically, I encountered the error:

---------------------------
ReSharper – Unit Testing
---------------------------
Cannot launch debugger.

Error code: 89710016

Error message: 0

when using R# 8.2 on VS 2013 Pro when attempting to debug NUnit tests.

After finding this link, the issue resolved by changing the NUnit class library project to x86 (Properties -> Build -> Platform Target : x86)

like image 22
StuartLC Avatar answered Oct 21 '22 16:10

StuartLC


Instead of changing the build properties of the Project to be x86 (which can impact other team members if working on a team), you can tell Resharper to run the unit tests in a 32 bit process.

Resharper -> Options -> Tools -> Unit Testing ->General -> Default Platform Architecture

Set this to "Force tests to run in 32-bit process"

like image 43
gardnebm Avatar answered Oct 21 '22 16:10

gardnebm