Varda Elentári
Varda Elentári

Reputation: 2322

"The breakpoint will not currently be hit. A copy of file was found in dll file, but the current source code is different"

I keep getting this error saying there's a copy of the .cs file hence the break point will not get hit.

I have tried cleaning solution, rebuilding , deleting the .pdb files in the obj and bin folders, closing VS and restarting it, restarting the whole machine (It's Windows! Sometimes the most complicated, unexplained problems get fixed like this :\ )

Any idea what else I can try? it's a .net project on VS2015

Breakpoint error

Upvotes: 25

Views: 25978

Answers (16)

Sasha
Sasha

Reputation: 8850

My case was terribly stupid: breakpoint was set in the other VS Project's Startup.cs (got mislead by Find Usages).

That being said, error-message is very misleading and it took a while and a coffee to open eyes wider and notice that. The count of different "solution" answers was also overwhelming.

Upvotes: 0

Muzammil Ismail
Muzammil Ismail

Reputation: 341

I am working on the Console App. Restarting the Visual Studio solved the issue for me...

Upvotes: 0

ulu
ulu

Reputation: 6092

Recycling the app pool did the trick for me

Upvotes: 0

Rosdi Kasim
Rosdi Kasim

Reputation: 25956

I am working on ASP.NET Core project, restarting Visual Studio does not solve it.

The only way to solve this by killing VBCSCompiler.exe process in the task manager.

Upvotes: 0

Ishola
Ishola

Reputation: 31

On Visual studio tools bar, do the following

  1. Goto Tools, Options
  2. Scroll to the Debugging item and click
  3. select the options General
  4. Disable the option REQUIRE SOURCE FILE TO EXACTLY MATCH THE ORIGINAL

Upvotes: 3

Narender Gandi
Narender Gandi

Reputation: 45

This is for those who have attempted all of the above approaches and still in search for the solution. I had similar problem, not matter what ever I do, I couldn't hit the break point. Finally, what I realized is the dll I am referring to is not the same one which IIS (root web.config) is using. The dll is installed in the GAC(Global Assembly cache) and that's the reason the debugger never hits and we see this kind of warnings. Follow these steps to resolve it:

  1. Find out the reference in GAC, at "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\YOUR DLL" and delete it. And install the newly modified dll, the command for installing is "gacutil -i YOURDLLWITHCOMPLETEPATH"
  2. Make sure you add the same dll in IIS root web.config location. (I was using customhttpmodule). In my case it was "C:\inetpub\wwwroot\WEBSITENAME\bin"
  3. Delete the temporary folder located at "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files"
  4. IISRESET

It worked for me, hope it works for you as well.

Upvotes: 0

gharel
gharel

Reputation: 573

IIS problem in my case, someone or some migration component changed the Physical Path of my web application (basic settings). Was not pointing to my solution on disk, but to another location with an older version of the app. Restoring the proper path, fixed it.

Upvotes: 2

sfarbota
sfarbota

Reputation: 2627

This can happen when you are debugging a .cshtml file with the same name as another file in the project. The debugger picks one of the files as the correct match (seemingly at random), so it will often find a mismatch when it compares the file from the Temporary ASP.NET Files to the source code in your project. The solution in my case was to rename one or both of the files from Standard.cshtml to something more specific.

Upvotes: 0

Rimi
Rimi

Reputation: 81

I had the same trouble and decided it by deleting attribute [System.Diagnostics.DebuggerStepThroughAttribute()] on the class.

Upvotes: 0

doby
doby

Reputation: 585

This can be due to pointing to the wrong library in your link.

When I got this problem, I had just started a new solution with an old project. I had not changed the target library in the Project->link->input section. So as soon as I made changes, I got this error. Each solution keeps a copy of the library.

Upvotes: 0

Varda Elentári
Varda Elentári

Reputation: 2322

I found the issue, it turns out IIS was configured to use a different copy of the project I had in my backup folder. It sounds pretty silly but I'll keep this question open if someone had something similar.

Upvotes: 11

AlexMelw
AlexMelw

Reputation: 2624

Despite the fact that my current project configuration was set to Debug, it seemed that it has been compiling as a Release one.

I removed (deleted) Web.Release.config from my project, recompiled solution, and then put Web.Release.config back.

Now everything works just fine. What a bizarre behavior, eh. :)

Upvotes: 0

Fakhar Ahmad Rasul
Fakhar Ahmad Rasul

Reputation: 1691

Incase someone is having the same issue, go to iis, then application pools on the left then select your application pool then on the right click on View Applications. Now under physical path you will be able to see the physical path to which your virtual path is mapped to, so make sure the physical path is pointing to the right folder and if incase it is not pointing to the right folder then remove your application from the app pool and add it again

Upvotes: 1

Luis Teijon
Luis Teijon

Reputation: 4899

Try rebuilding the solution.

Sometimes there are post-build scripts that copy the DLLs from one project to another in order to keep the DLLs updated in different projects. If you modify and compile just one project, then some of these scripts might not be executed and the old DLLs might not be updated.

Upvotes: 0

Dave
Dave

Reputation: 1045

Here are some things to look at:

  1. If you've recently changed namespacing or class names, an old version of the dll may be hanging around in the asp.net cache. Often deleting the files here and rebuilding will solve the issue.

c:\Users\yourname\AppData\Local\Temp\Temporary ASP.NET Files\

  1. Check your views to make sure your referencing the right class names.

Upvotes: 4

TechnicalTophat
TechnicalTophat

Reputation: 1725

Check the physical directory the CS file is stored in, there may be two seperate files, and if not open the .csproj in a text editor (not VS). See if the file is referenced twice. If so, just delete one of the lines. If that doesn't work, you could always do what it says and set the breakpoint location :)

Upvotes: 1

Related Questions