12
votes

.NET 4, console application. The project is set to 'Debug' mode. The breakpoint being set is in the primary/startup project. I have right-clicked -> Clean, and right-clicked -> rebuild, both on the Solution and project levels.

Following the instructions in this SO question, I have confirmed that my "Build and Run" options are set to 'prompt' for both 'When projects are out of date' and 'when build or deployment errors occur', and I am NOT getting a prompt when I F5 to build/run.

Also, the 'save all changes' under 'before building' is also selected (plus I manually saved them myself).

I monitored the output window of the application, see this line:

 'MyApplication.exe': (Managed (v4.0.30319)): Loaded 'C:\exepath' Symbols Loaded.

I restarted the VS2010 instance. I restarted all open VS2010 instances (of other projects). I've even gone through a reboot.

However, the breakpoint I am setting in the startup project is a hollow-red circle, with the notice that 'This breakpoint will not currently be hit, The source code is different from the original', and, in fact, is never hit.

So, this is really 2 questions:

1) How do I fix this problem so I can properly breakpoint

2) When I see this, does that mean my code is executing from an older build?

12
When it is running and you look in the task manager, processes, properties what is the location it is run from?Eddy
@Eddy c:\path\to\working\directory\bin\debugCoolUserName

12 Answers

9
votes

I've had this problem once myself but that was on a vsto addin. In that case there were left over intermediate files under the users/appdata directories that were actually loaded instead of my app.

There is this blog article that has a whole load of possible reasons for this error and then a whole bunch more in the comments from other users

3
votes

This can also happen if you have a solution with multiple projects, and have the wrong project selected as your startup project in VS2010 and VS2012.

Now, obviously, I wouldn't expect debugging to work if I have the wrong startup project selected -- the debugger is attaching itself to the wrong process!

But this error message (in my case) was terribly misleading. It made me think something else was wrong. I tried a bunch of solutions in this thread (nuking various /bin and output directories) when really it was something very simple (wrong startup process).

1
votes

If you are using vb, check that you are building the project for the active solution configuration (Build, Configuration Manager..., Column under Build is checked. Also check the project properties, Compile tab, Advanced Compile Options, and Generate debug info is set to Full. Sorry I can't tell you where this may be in C#.

The only other time I've seen this is when two projects in the solution are referencing the same dll but they are referencing from different sources. One from a project reference and another from a file reference for example. If the "copy local" option is true, there would be the potential of overwriting the dll with an older version of the same dll.

1
votes

My solution might help people who have signed the assembly.

After lot of head scratching for the past two days, I was able to resolve the same issue by doing the following simple steps:

  1. Go to your Visual Studio project properties.
  2. Go to the "Signing" tab.
  3. Uncheck "Delay sign only" option if it is checked.
  4. Now run your project and it should work.For me it did work.
1
votes

In my case was this same problem (“The breakpoint will not currently be hit. The source code is different from the original version.”) caused by fact, that I tried add breakpoint to declaration:

DateTime dt;
bool b = DateTime.TryParse(null, out dt);

(first line of code)

So I assume that message is "universal" and may have many different causes.

0
votes

This can happen if your system clock was changed since the last compile. Your PDB file will be different date than the one your are trying to debug. Delete the PDB files in the project and recompile.

0
votes

I experienced the problem when Project > Properties > Web did not have "Enable Edit and Continue" selected. After enabling this feature the issue was corrected.

It is important to note that under Tools > Options > Debugging > Edit and Continue "Enable Edit and Continue" was selected, but it was not enabled for this project.

0
votes

Just go to Tools / Import and Export Settings Choose reset all settings then click Next No, just resetl settings, ovewriting my current settings then click next Choose your current language, por example C#. then click Finish

0
votes

If you have multiple solutions open, try simply closing all Visual Studio instances and restarting only the instance you need. In my experience this has happened when two branches of nearly identical code are open in different instances.

0
votes

doing a "clean solution" from VS Build Menu might help you.

0
votes

I had to go over all those steps to fix the issue on my computer.

  1. Make sure that debug = "true" on your web.config

  1. Clean and rebuild all projects

  2. Delete every file inside the bin folder of all projects

  3. Close and open Visual Studio, rebuild, and run the project again.

0
votes

Go to your solution folder -> obj -> Debug - > delete the .dll file and build the solution again.