I have a class that looks like this:
public class MyService
{
private MyService(){}
public static string GetStuff()
{
var stuffDid = new
I've recently had the same problem and was smashing my head against the wall.
The answer turned out to be pretty silly: Somehow my test project got out of sync with the main library project. I was building the debug versions of the test and library, but the test project copied the library from the bin/Release
folder. I just recreated the project reference and everything was fixed.
P.S. It was even criazier: the debugger went inside a library function, but somehow skipped one line in the middle of it.
In Unit Tests, I was not hitting breakpoints, and realized I was Running the test and not Debugging the test. At the top of the Test Explorer are the options "Run All", "Run Failed", "Run Passed", etc. When you Run a test, breakpoints are not hit. To Debug a test, in the Test Explorer right click on the test or group of tests and select Debug Selected Tests.
I know from experience that Visual Studio does not have a clear method of debugging services, especially Windows services. Try adding some code to GetStuff to print to a text file, this way you at least know the code is getting hit. When creating services I often fall back on this method for testing.
First try rebuilding your project by right mouse click the project > Rebuild If that doesn't work, try a clean of the project (right mouse click on the project > clean)
If that didn't work check this:
Right mouse click your project
select [Properties]
select the [Build] tab
make sure [Define DEBUG constant] and [Define TRACE constant] are checked
Click the [Advanced] button at the bottom of the Build tabpage
Make sure that [Debug Info:] is set to [full]
Click [OK] and rebuild the project ;-)
Hope that works for you! (step 6 generates the .pdb files, these are the debugging symbols)
Clean the solution and rebuild and also do the start up project.
Can you please have a quick look at the BUILD > Configuration Manager, just to sure what are the configuration properties are set up. If it is development then you might have to adjust the Project Properties -> click advance setting -> change debug info to 'full' in [output tab].
you can also follow step two even it is not development mode
It turns out this was related to Code Coverage being on.
Turning it off fixed the issue.
You can find out how to disable code coverage by following below link
Disable code coverage