VS2015 - "The breakpoint will not currently be hit. Unable to find corresponding location"

Unity version: 5.5.1 OS: Windows 10

I cannot put some breakpoints in Visual Studio 2015 to debug my Unity project. It seems to allow breakpoints 50% of the time, but it happens consistently across unity projects. I don’t have this problem with other types of VS projects.
Visual Studio tools for Unity is installed.
Things I have tried:

  • Reinstalling Unity, VS and VSTU
  • Running as administrator
  • Re-creating a project by scratch (deleting folder + re-importing all the assets)
  • Deleting the Library folder
  • Deleting project settings
  • Changing advanced build settings “debug info” from “pdb only” to “full”

…should I just give up? :frowning:

1 Like

Hitting this as well starting with 5.5.1. Windows 10, VS 2015. Only some of my source files are affected…

This generally happens when somnething in the source (or the project file) has changed, so it’s not sure if it can hit the breakpoint. This isn’t specific to Unity but it looks like something changed that’s causing this behaviour with 5.5.1. Something is changing a code file somewhere. Close the solution in visual studio, then reopen it by clicking a .cs file in Unity and see if that makes the issue go away (at least temporarily).

1 Like

This is what I did:
Close solution → double click .cs file in Unity → solution opens (in another VS instance) → Attach to Unity → Start Unity

But the breakpoint is still not being hit.
I checked the files in the Assets folder and the .proj file, and none of them have changed between the time I open the solution and the time I start unity.

Weird. In the build configuration dropdown at the top, is the configuration set to Debug?

Yes - Debug & Any CPU

I would try reinstalling Visual Studio Tools for Unity. It seems like the debugger isn’t syncing properly with the project source.

Nvm… I see you already tried that.

did someone found a solution?
Same thing here :frowning:

I have sent an email to VSTU support. If I get an answer I will post it here too.

I’m seeing this too in 5.5.1.

I’m using 5.5.0 and got the same issue :slight_smile:

Well, mine suddenly started working again. I have no idea why.
My breakpoints still have that error message, but only when they are on scripts not attached to the current scene.
When I load a scene they activate and break appropriately.

It’s possible that something I did in the OP fixed it, although it wasn’t apparent because the breakpoints still showed the same message.

2 Likes

I ran into this issue today.

Deleting my sln and csproj files got me to a state similar to where soreric was at in the latest post: The breakpoints still say they are broken, but they work. When a breakpoint is hit, the false broken icon / message goes away. I only tried this on one file, so I am not sure if hitting one breakpoint would solve the erroneous messaging globally.

The script I was testing was attached to an object in the scene. I did not check any other state.

I have the same broblem. 5.5.1. Windows 10, VS 2015 In new .cs files breakpoints have that error. But in old fils of project it’s working well.

Here’s something interesting to check… take one of your new .cs files and open it in Notepad++. First:

Click the “Encoding” menu and make sure it’s set to “Encode in UTF-8”. Not with the BOM, just the Encode in UTF-8 option.

Next, click the “Edit” menu. Go down to “EOL Conversion” and see what that’s set to. If it’s set to “Windows” then that option will be greyed out. If it’s not, then select it. Then open that .cs file again in Visual Studio and see if the breakpoint can be hit.

2 Likes

I did it. After this a breakpoint still couldn’t be hit. But after first running a game it fixed. I change encoding in only one new .cs file and breakpoints fixed in all new .cs files. This is strange. But I think it was a reason of my problem.
Maybe is there a way to create new .cs file in correct encoding in unity?
Thank you for your help.

That’s the only thing I could think that Unity might have changed that would have caused this. It’s possible the new docs are getting created as UTF16 or UTF8 with BOM and Visual Studio is getting confused and doesn’t know how to map the code in the file to the generated byte code (so doesn’t think it can hit the break point).

영어를 못해서 한국말로 쓸게요…

  1. 새로운 빈 프로젝트를 만드세요
  2. 빈 스크립트를 만들어 메인카메라 같은데 붙여보세요
  3. 적당히 코딩후 브레이크 포인트를 추가하고 vs2015를 유니티에 어태치 시켜보세요… (제대로 연결이 안됬다고 나올겁니다.)
  4. 하지만 실행 시켜 보세요… 제대로 브레이크 포인트가 잡힐겁니다.
  5. 빈프로젝트를 닫고 안잡히던 프로젝트를 열어보세요.
  6. 여전히 깨졌다고 나올겁니다. 하지만 실행시켜 보세요. 잡힐겁니다.

Roughly translated using Google Translate:

1 Like

I have the same problem when I update the version from 5.4.3 to 5.5.2.
I found my problem is because my xxx.dll reference the old version “UnityEngine.dll”. so I change the reference file with new version, and it working right now.
I don’t know if it will work for you.

2 Likes