Search Unity

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

Discussion in 'Code Editors & IDEs' started by soreric, Feb 6, 2017.

  1. soreric

    soreric

    Joined:
    May 8, 2014
    Posts:
    13
    Unity version: 5.5.1 OS: Windows 10

    upload_2017-2-5_22-54-48.png

    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? :(
     
    TomaszKozera likes this.
  2. dajyareo

    dajyareo

    Joined:
    Dec 7, 2014
    Posts:
    11
    Hitting this as well starting with 5.5.1. Windows 10, VS 2015. Only some of my source files are affected...
     
  3. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    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).
     
  4. soreric

    soreric

    Joined:
    May 8, 2014
    Posts:
    13
    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.
     
  5. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Weird. In the build configuration dropdown at the top, is the configuration set to Debug?
     
  6. soreric

    soreric

    Joined:
    May 8, 2014
    Posts:
    13
    Yes - Debug & Any CPU
     
  7. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    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.
     
  8. lovenothing

    lovenothing

    Joined:
    Jan 24, 2017
    Posts:
    2
    did someone found a solution?
    Same thing here :(
     
  9. soreric

    soreric

    Joined:
    May 8, 2014
    Posts:
    13
    I have sent an email to VSTU support. If I get an answer I will post it here too.
     
  10. Adam-VisualVocal

    Adam-VisualVocal

    Joined:
    Sep 22, 2016
    Posts:
    10
    I'm seeing this too in 5.5.1.
     
  11. lovenothing

    lovenothing

    Joined:
    Jan 24, 2017
    Posts:
    2
    I'm using 5.5.0 and got the same issue :)
     
  12. soreric

    soreric

    Joined:
    May 8, 2014
    Posts:
    13
    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.
     
    stormarch likes this.
  13. doday

    doday

    Joined:
    May 12, 2015
    Posts:
    41
    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.
     
  14. AlexFreeman

    AlexFreeman

    Joined:
    Sep 29, 2016
    Posts:
    12
    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.
     
  15. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    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.
     
  16. AlexFreeman

    AlexFreeman

    Joined:
    Sep 29, 2016
    Posts:
    12
    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.
     
  17. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    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).
     
  18. sangryul

    sangryul

    Joined:
    Oct 28, 2016
    Posts:
    1
    영어를 못해서 한국말로 쓸게요..
    1. 새로운 빈 프로젝트를 만드세요
    2. 빈 스크립트를 만들어 메인카메라 같은데 붙여보세요
    3. 적당히 코딩후 브레이크 포인트를 추가하고 vs2015를 유니티에 어태치 시켜보세요.. (제대로 연결이 안됬다고 나올겁니다.)
    4. 하지만 실행 시켜 보세요.. 제대로 브레이크 포인트가 잡힐겁니다.
    5. 빈프로젝트를 닫고 안잡히던 프로젝트를 열어보세요.
    6. 여전히 깨졌다고 나올겁니다. 하지만 실행시켜 보세요. 잡힐겁니다.
     
  19. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Roughly translated using Google Translate:

     
    AmazinJacks likes this.
  20. Wayne1228

    Wayne1228

    Joined:
    Feb 26, 2017
    Posts:
    1
    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.
     
    sier_ua and MyoungSu-Go like this.
  21. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Useful observation: I saw this when the class I was trying to breakpoint was not ... loaded / initialized (?). This might explain some people's experience of seeing the warning in VS then it seeming to work once tried?
    HTH, Rupert.
     
  22. yshimm

    yshimm

    Joined:
    Mar 8, 2017
    Posts:
    1
    same problem with latest unity 5.5 here
     
  23. Amazi

    Amazi

    Joined:
    Dec 30, 2013
    Posts:
    2
    I'm having the same issues with Mono-develop on the Mac. The last Unity version in which breakpoints behaved correctly was version 5.4.3f1. I've tried several updates since December with no luck.

    Unity claimed this issue was fixed : https://issuetracker.unity3d.com/issues/breakpoints-do-not-trigger-in-monodevelop

    I've filed a new bug ticket today : case 889998 after spending the last day trying with various versions of Unity including the latest 5.6.0b11 (beta). I created a brand new empty project with just one scene, one c# file, same problem :(

    The frustrating thing about this issue is that many people have been complaining about breakpoints being broken since way back in December on both Visual Studio and Mono-develop and Unity literally haven't taken it seriously.

    I'll post back to this thread if Unity shed any light on the subject.

    More references : https://forum.unity3d.com/threads/monodevelop-debugging-breakpoints-do-not-work-in-play-mode.444685/
     
    Last edited: Mar 16, 2017
    MihaPro_CarX likes this.
  24. Amazi

    Amazi

    Joined:
    Dec 30, 2013
    Posts:
    2
    Not sure if this will work on Visual Studio but I found an awkward work around for Unity 5.5+ for MonoDevelop.

    Add the following code just above something you want to debug, and magically breakpoints can be placed (and trigger) on the if statement allowing you to single step down the code.

    Code (CSharp):
    1. if (System.Diagnostics.Debugger.IsAttached) {
    2.     Debug.Log( "Debugger Is Attached!";
    3. }
    Note : You may have to add/remove the breakpoint a few times for it to show as a solid red circle.

    Please let me know if this works for Visual Studio and I'll update the ticket I have open with Unity.
     
    Last edited: Mar 13, 2017
    MihaPro_CarX likes this.
  25. friuns

    friuns

    Joined:
    Jan 14, 2016
    Posts:
    23
    same here nothing helps...
     
  26. friuns

    friuns

    Joined:
    Jan 14, 2016
    Posts:
    23
    is everyone here installed visual studio 2017 lattely? i suspect it started happening after installing visual studio 2017..
     
  27. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I run 2015 and 2017 side by side and haven't had an issue.
     
  28. friuns

    friuns

    Joined:
    Jan 14, 2016
    Posts:
    23
    ah nvm its seems some new unity feature, that if you dont add script to object on scene it will show that error..
    but actually it hits breakpoint even if its shows that error

    but for mono i had similar issue here how its solved, not sure if it helps here..
     
  29. k0mbain

    k0mbain

    Joined:
    Nov 1, 2012
    Posts:
    22
    Same here, I updated from 5.4.3p4 to 5.2.2p1
    Tried everything, clearing MEF cache, saving file in UTF-8 without BOM, reinstalling VSTU...
    I'm using VS 2015 Update 3 Enterprise.

    Edit.
    I removed Library folder to make Unity rebuild it.Until one is hit it seemed like disabled with message "The breakpoint will not currently be hit...", but it is working!
     
    Last edited: Mar 20, 2017
    bbedard75 likes this.
  30. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    Bump, I'm getting this with 5.6.1p1. Visual Studio 2017 Community. Same info as people above, nothing new to add :/ any official word on this? Anyone report this within Unity?
     
  31. jeenfang

    jeenfang

    Joined:
    Nov 25, 2013
    Posts:
    1
    you open the two or three unity project. it will be show
     
  32. jl008

    jl008

    Joined:
    Jan 31, 2013
    Posts:
    25
    VS Community Edition 2017 Version 15.2 (26430.16)
    .Net version 4.6.01055
    Unity version 2017.1.0f3
    Win 7

    The problem persist. None of the above solutions worked.

    Edit: I take it back. The removing Library solution worked. (as described above the breakpoints still give you warning but they hit)
     
    Last edited: Jul 19, 2017
  33. Anisoropos

    Anisoropos

    Joined:
    Jul 30, 2012
    Posts:
    102
    Unity 2017, VS Community 2017, I get the warning but it goes away as soon as I hit play and gets properly hit every time. Maybe it's waiting until there is an instance of the script in question before enabling the breakpoint?
     
  34. Magnumstar

    Magnumstar

    Joined:
    Oct 3, 2015
    Posts:
    304
    I'm encountering this as well in unity 5.4.0f3
     
  35. Deleted User

    Deleted User

    Guest

  36. SlimeEnthusiast

    SlimeEnthusiast

    Joined:
    Mar 2, 2015
    Posts:
    7
    I was having this exact same problem, and the solution turned out to be something totally different than anything posted in this thread. After trying almost everything posted, I happened to notice that my editor was in a scene called "Untitled" despite the fact that it had all of the same objects in the scene I was actually trying to edit. Closing and reopening the editor loaded up this same Untitled scene. I opened up the actual scene which loaded in looking identical to this Untitled scene and suddenly all my breakpoints began to work!

    I doubt this is the issue for most people getting this error, but I figured I had to post in case anyone was pulling their hair out trying all in-VS suggestions to no avail!
     
  37. LacunaCorp

    LacunaCorp

    Joined:
    Feb 15, 2015
    Posts:
    147
    Also running into this as of today; VS 2017, Unity 5.6.2p4, C#7, NET 2.0 full. Reinstalled, thoroughly cleaned and rebuilt all assemblies, killed SUO and so on. Unlike other reported cases the breakpoints will not execute at all in my case; lazy logging shows that the method is failing to execute at all. Interestingly, this is only being flagged for certain classes; nothing frontend (i.e. MonoBehaviours). Due to performance concerns I only use a very small handful of MonoBehaviours which are just proxy objects to access backend classes; all game logic is plain C# or packed into external DLLs. I'm now wondering if this is some constraint placed by VSTU, (as counterintuitive as it seems, there is no obvious reason I can think of which would only allow scene-initialised behaviours to be debugged) due to other peoples' experiences. The pattern seems to fit that I'm only able to place breakpoints on MonoBehaviours; it's flagging for any plaing C# class, be it some backend object or a simple static data helper.

    EDIT: To clarify, the plain C# classes I'm trying to work with are instanced and operating correctly for the most part. It is as though certain elements are missing entirely from compilation.
     
    vrdev004 likes this.
  38. SecondCobra

    SecondCobra

    Joined:
    Jan 25, 2017
    Posts:
    31
    Hi, I've just had this and tried everything I could find from the forums with no success. Then I tried deleting every single .meta file in my Unity project and that *seems* to have fixed it. I say seems because there was a reboot in between but I'm guessing that didn't do it. Anyway, hope that helps.
    EDIT: This also fixed a problem I was having with my script not responding to button presses on my Vive controllers, so something was likely corrupted in a meta file somewhere.
     
    Last edited: Oct 14, 2017
  39. Twelewen

    Twelewen

    Joined:
    Aug 4, 2015
    Posts:
    4
    Hi.

    I was having this problem as well. For me, full project rebuild AND deploying all rebuilt binaries into Unity plugin folder helps.. I gues this problem might be related to having open differend source code in Visual Studion IDE and other in Unity. This might happend during rebuild event.

    So my advice is:
    If you are using any plugin (DLL) make sure to have actual DLL present in Unity plugin folder. I have set my Visual studio build events to automatically copy newly built binaries into Unity plugin directory.

    Hope that helps,
    Cheers
     
  40. goonya

    goonya

    Joined:
    Apr 23, 2017
    Posts:
    1
    For my problem, I had to add the debug file (PDB) to the Unity asset folder with a post-build step:
    Code (CSharp):
    1. copy $(TargetPath) $(SolutionDir)Assets
    2. copy $(TargetDir)$(TargetName).pdb $(SolutionDir)Assets
     
  41. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    2017.2.0p2, VS 2015, same problem here.
     
  42. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    The problem also occurs in Rider, so it's not specific to VS.
     
  43. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    2017.3 1f1 with the same issue
     
  44. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Back again in 2017.3.1f1, VS Community 2017 15.7.0, after importing an asset I cannot set breakpoints in one of its classes.

    edit: problem went away again. beats me.
     
    Last edited: Jun 1, 2018
  45. Deleted User

    Deleted User

    Guest

    I've never had the problem with VS Code. Maybe switch to that? Of course I haven't used the debugger too much...
     
  46. TomaszKozera

    TomaszKozera

    Joined:
    Oct 18, 2017
    Posts:
    14
    I'm having the same issue with Unity 2017.4.0f1 and Visual Studio 2015 (with latest updates).

    In one of my files, no matter where I place the breakpoint it's not detected. Other files work without issue though.
    Previously I used to debug that file and had no issue - this just popped out, seemingly, out of nowhere.

    Here's what I tried (and didn't work):
    • restart Visual Studio
    • restart Unity
    • rebuild project in Visual Studio
    • reboot the machine
    • change scripts and wait for Unity to reload them after change
    • reimport all project assets in Unity
    • clean & build project in Visual Studio (instead of just rebuild)
    Edit:
    Ok somehow now it started working for no reason, even though the breakpoint was blank and reported as not working, when I run the code it got caught o_o...
     
    Last edited: Jul 26, 2018
  47. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Back again in 2018.2.6f1 / VS Community 15.8.7
    Tried:
    All kinds of restarting; Deleting .vs, Library, obj and Temp folders; Upgrading VS
    Nothing works.
     
  48. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Been trying for a week to fix this. Some things I've come across

    If you start debugging, go to Debug > Windows > Modules, you can see a list of modules loaded. In here you can find your assemblies and might note that symbols are not loaded for the assembly you want to put breakpoints in. You might be able to load your symbols in from there. I wasn't.

    What I found was that trying to load these symbols from the pbd doesn't work for some reason (the symbols can be found in obj/Debug) and it's possible that there's some conflict - I've seen pages that said if you change the .NET compatibility level that can fix it (Go to Edit > Project settings > Player > ApiCompatibilityLevel and change it to .NET 2.0 instead of .NET 2.0 Subset). This didn't work for me.

    One page suggested right clicking an assembly in the modules window and selecting "Symbol Load Inofrmation..." but that did nothing for me - it's supposed to show you which locations VS searched for the assembly in which would be good info to have I suppose. Anyway it doesn't seem to work

    Another page suggested using Attach to Process instead of Attach Unity Debugger, and changing the Attach To: settings to include the .NET 2.0 and Unity categories and that didn't work either.

    So I've done all that on top of deleting all Library/temp/obj/vs files and nothing's working so I'm gonna delete Unity and my project and reinstall/pull them again, and if that doesn't work I'm going to throw myself out of a tall building.
     
    adefilippis and AxelMG like this.
  49. EmiGD

    EmiGD

    Joined:
    Dec 21, 2016
    Posts:
    3
    I had this problem today. It turned out that the method which was invoked in this line when the symbol was being shown as "not currently hit..." was labelled as [System.Diagnostics.Conditional( "DEBUG_LOG" )] and I didn't have DEBUG_LOG added in the Project Settings. So the metod wasnt present in the compiled code, but Unity and Visual didnt signalize it in any way.
     
  50. jimmy14mac

    jimmy14mac

    Joined:
    Dec 8, 2013
    Posts:
    6
    Ran into this problem today. What fixed it for me is making sure the script with the problem was on a game object in my current scene. Once I dragged it into the scene, I got a bunch of errors related to the script that needed to be fixed. Then the break point was able to be hit.
     
    MagiJedi and Bulbware like this.