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. guneyozsan

    guneyozsan

    Joined:
    Feb 1, 2012
    Posts:
    99
    Currently I'm on 2018.2.15f1 with Visual Studio 2017 15.8.6, but I run into this every once a week in almost all Unity 2018 versions. How it appears and how it is fixed looks pretty random that something under the hood needs a solid fix!

    Sometimes it disappears, sometimes it comes back. For a few of the cases `Clean Solution/Rebuild solution` worked. For a few others changing expression body to block body fixed. And in some cases it hits the breakpoints although it says it won't. I tried switching .NET versions to Rebuild library, and some other things like BOM, EOL. of cs files. I think I tried all solutions except Load symbols thing. Just I'm bored, project stalling and I'm going back to Debug.Logging.

    And weirdly enough sometimes the ratio of not-hitting breakpoints increase as I try solutions, that is previously hitting breakpoints get infected and turn into that yellowish white breakpoint dots one after another.
     
  2. guneyozsan

    guneyozsan

    Joined:
    Feb 1, 2012
    Posts:
    99
    Ok, more weirdly enough I went to lunch with Unity and Visual Studio open in the background (debugger not running), and all of the problem breakpoints were hitting when I was back half an hour later.

    I'd seen a few breakpoints turned to red after a few seconds, so maybe VS is doing a kind of indexing in the background and some of these take too long. Meanwhile we try to fix the problem and a random fix looks it is working. Or some fixes accelerate that process. Can something like this be related?
     
  3. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Complete mystery to me. Still never got to the bottom of it.
     
  4. stack86

    stack86

    Joined:
    Jul 22, 2016
    Posts:
    11
    I'm on Unity 2018.2 and I'm getting this issue too, but I get 100% of the time, previously I just used MonoDevelop on the older versions of Unity and it was fine, since upgrading, the first day I used Unity I was able to breakpoint in VS, but never again after that, it is infuriating that I'm now rendered completely unable to debug. I have tried all the suggestions floating around, it just won't work, and looks like it never will. I am thinking I need to open a support ticket but I have no faith I'll get a useful response... this is making development very difficult, I'm going to see what other tools I can point Unity too for debugging (maybe I can just go back to MonoDevelop?)

    EDIT: Yes I was able to just go back to MonoDevelop, I just switched Unity's preferences (External Editor) to open by file type, since Mono is still installed and still associated. And while it isn't as nice and pretty as VS (trust me I love VS, I use it for everything else), it is able to hit breakpoints, so it's the winner.
     
    Last edited: Nov 27, 2018
  5. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    It's 2019 and still happening ...... VS2019 + Unity 2019

    Absolutely none of the solutions worked for me

    FWIW

    This is what worked for me:

    I had a MonoBehaviour that is a partial class, as soon as I opened the second file of the partial class, breakpoints could be magically hit again :)
     
  6. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I switched to Jetbrains Rider roughly a year ago and have never looked back. Can't remember having an issue since. I know it's not super helpful in terms of VS, but I personally cannot recommend Rider enough.
     
    aybeone likes this.
  7. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    I know that Rider is great and I too use it, it does not choke on a tooltip array of 1000s elements contrarily to VS :).

    But there are features in VS not in Rider hence why I (still) have to use VS.
     
  8. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Can I ask what features? I have found the feature set of Rider to be much better in my opinion and have not noticed anything lacking.
     
  9. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    Mainly class diagram,

    A few UX things like activating Unity window back when you continue execution so you don't have to Alt-Tab each time,

    Debugger in general,

    Other things like live unit testing, code map but these are for Enterprise version.

    And you know, the interface, after years of VS it's hard to change even though I have the same font and many enticing features.

    But don't get me wrong, the simple fact that Rider has R# and is fast and does not choke in debugging simple arrays is enough to switching entirely :)

    VS + R# is just insane, many times it slow to a crawl after a long period, seems like you're on an 286 :mad:
     
  10. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Resharper itself has some architectural and dependancy diagramming tools, if that is what you are referring to? Also, too bad it is not a 386. My DX/2 could just hit Turbo. : P I don't remember if my 286 had that. :p
     
  11. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    I know and they're pretty good actually. But you know, good ol' class diagram has its qualities :).

    There's code map too but it's so sluggish that I stopped using it.

    You can see at Jetbrains that they're planning to roll out stuff in 2019.1, hopefully we'll get many new features!

    I do miss my DX/2 66 actually :D

    Memories memories!!!
     
  12. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Looks like class diagrams might be one of the things to make it into 2019.1 actually. : D
    https://youtrack.jetbrains.com/issue/RIDER-4321

    But yeah, memories, lol. Much simpler times, indeed. Getting my first sound card was amazing, lol.
     
  13. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    Yeah hopefully!

    Back then I had a whopping 16mb of memory but no SB... When I got one however, I instantly became the king :) today it's all about the numbers, nothing more :(

    There are still few good games today but it's not like how it used to be!
     
  14. SandeepMahale

    SandeepMahale

    Joined:
    Feb 18, 2019
    Posts:
    1
    I also ran into same problem.
    I followed a different way to add the script in Unity (may be a wrong way). I copied and pasted the script in Windows Explorer and renamed it. Also updated the class name and adapted the implementation where ever I wanted to.
    After this, I was not getting breakpoints hit and got same error message.

    Then I newly added the script from Unity and replaced the code which was added during above step.
    After this breakpoints were hit.
     
  15. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    Now I've got this issue on 2019.1.2f
     
  16. dbarile

    dbarile

    Joined:
    Apr 14, 2015
    Posts:
    14
    Thank you Amazi! This worked for me. It's a super weird hack, but did the trick. After I added that line of code and it worked once, I was able to delete the code and it continued to work.... FOREVER!
     
  17. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    Hey all,

    Found a reliable workaround for our project. The issue is with .mdbs

    Our codebase lives outside of unity. We compile it in visual studio and copy over the .dlls and .pdbs.
    Not sure if the fault is ours or unity's, but in order for breakpoints to work, we should be updating/generating new .mdbs every time.

    For whatever reason, the .mdbs do not always update. If your breakpoints aren't working, open your assemblies folder in windows explorer and verify the update date on the .mdbs are what you'd expect (or that the .mdb for your .dll exists at all).

    The workaround:

    We found that if we delete all our .dlls and .mdbs from our unity project, build in VS and copy them over, then select them in unity and hit "Reimport" (not reimport all, that will take forever!), this almost always updates the .mdbs.

    It's a pain, and likely something to do with our post-build copy setup, but it is reliable.

    Hope this helps someone
     
  18. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46

    Found a less burdensome, but still not ideal solution. There is an executable that runs on windows called pdb2mdb.exe. Found out running this against all our dlls after copying them into unity seems to generate/update all the .mdbs and allow debugging. Made a .bat script to do so. Of course this means manually clicking this .bat every time I want to debug now.
     
  19. Twelewen

    Twelewen

    Joined:
    Aug 4, 2015
    Posts:
    4
    Here is a solution how I am able to debug any code without any issue now. I have been having this issue for 5 years so far making me wanna jump out of the window many times. Here is a list of checks I am doing before every debuging sesion and I haven't experienced a single debugging issue since than. Some steps may be ommited probably

    - Detach Visual Studio debuger from Unity
    - Stop unity project running if any
    - Recompile your solution (deploy DLLs into plugin directory)
    - Let Unity recompile imported DLLs
    - Reimport all plugin directory in Unity (wait for the work-in-progress bar)
    - Visual studio start doing dome heavy work (you can check in Task Manager cpu load). You need to wait till it finish processing and if you interrupt this process either by Unity Run button or attaching Visual Studio debuger to Unity you ended up with non-working breakpoints. Wait till you see the heavy cpu work is done in Task Manager - took 20 sec for me.
    - Hit Unity play button and wait till it starts
    - Attach Unity Debugger
     
  20. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    Occurring again in 2019.4.4f1, VS Professional 2019 (16.7.4). VS Tools For Unity 4.7.10. Very tired of this
     
  21. NotExplosive

    NotExplosive

    Joined:
    Dec 24, 2019
    Posts:
    1
    Hello from 2020! I encountered this today. I found that anywhere in this particular file I would get this error message along with the "hollow" breakpoint. I could apply breakpoints in other files but not the one that I cared about. Annoying right?

    Here's where it gets weird: I just ran the game as normal and pretended like the error didn't happen, the breakpoint did actually hit. So the error message was just lying.

    Not sure if that matches other people's experience.
     
  22. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    198
    I have found that sometimes setting the breakpoint depends on the state of the editor yeah, and once you actually start play, the breakpoint location can be resolved.
     
  23. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Still happening in the latest versions of Unity. It is absolutely ridiculous we still can't use Visual Studio to debug our code.
     
  24. mob5

    mob5

    Joined:
    Aug 5, 2017
    Posts:
    3
    Is there still no solution? I've been having this issue for so long now. Does this occur with other IDEs as well or just VS?
    I've tried everything I can think of and all possible solutions online but nothing works. Sometimes it just works and 99% it just doesn't and I have to resort to debugging with print statements like in the dark ages!
     
  25. unity_o0Rb3j1Hs4Bm8A

    unity_o0Rb3j1Hs4Bm8A

    Joined:
    Jan 13, 2021
    Posts:
    1
    I had the exact same error message. If someone reading this today against all odds may have the same cause of the problem as me: The script that i tried to debug with my breakpoint was not attached to any game Object.
     
  26. KiteLionGames

    KiteLionGames

    Joined:
    Dec 27, 2016
    Posts:
    7
    Fixed this for me. Unity Console: "Missing Script" Warning. Fixed the warning, debugger worked again. I also i tried running build in solution in VS. Guess it wasn't completely compiling correctly outside Unity cuz of the warning.
     
  27. SilverLifeee

    SilverLifeee

    Joined:
    Oct 16, 2020
    Posts:
    2
    This problem might be fixed if you delete Library and obj and all csproj and sln files in the highest hierarchy level of the project Folder (where you can also find your Assets folder) and reopen the project afterwards . Unity will rebuild its library and debugging will work again.
     
  28. SilverLifeee

    SilverLifeee

    Joined:
    Oct 16, 2020
    Posts:
    2
    I guess the c# sln file which is being created by unity gets corrupted somehow and has to be rebuild.
     
  29. Unitybengi

    Unitybengi

    Joined:
    Sep 11, 2020
    Posts:
    1
    You may have been wrote the method to a wrong class.
    Thats why you may be getting "breakpoing will not be hit" error.
    I had the same error and solved this error with this.
     
  30. GianfrancoLe

    GianfrancoLe

    Joined:
    Jan 5, 2018
    Posts:
    1
    in VS
    Debug
    Attach Unity Debugger.
    A pop up shows, you select the line with your Unity process.
    This worked for me.
    ad maiora!
     
  31. sicklepickle

    sicklepickle

    Joined:
    Apr 8, 2012
    Posts:
    44
    Underrated comment, tbh.
    I think a lot of people haven't realised that this seems to fix it for the rest of the session...

    So by doing something like this (or a main menu item) + putting a breakpoint on the Debug.Log():

    Code (CSharp):
    1.     [ContextMenu("Fix Debugger")]
    2.     public void FixDebugger(){
    3.         if (System.Diagnostics.Debugger.IsAttached)
    4.         {
    5.             Debug.Log("Debugger Is Attached!");
    6.         }
    7.     }
    Still dealing with this in 2022 btw. Not surprised, but truly disappointed that Unity is such an ongoing shambles right now.
     
  32. bbedard75

    bbedard75

    Joined:
    Feb 21, 2017
    Posts:
    3
    Removing the Library and obj folders fixed this for me. I had copied the project to a new folder before this so that might have been the reason the code got out of sync.
     
  33. TahaHassan42

    TahaHassan42

    Joined:
    Jul 7, 2023
    Posts:
    1
    No need to worry guys the breakpoint is created and it will be hit if that piece of code is run. It just simply says it cannot be hit because either the piece of code is not running or the script is not included in the scene.
    In my case. the breakpoints acted this way because on the runtime that gameobject was disabled and all but as soon it got enabled the breakpoint hit smoothly
     
  34. Hanbabang

    Hanbabang

    Joined:
    Aug 10, 2023
    Posts:
    1
    Finally, I find a way to avoid it.
    If you use github, you can upload you repo to it, and git clone it to another folder at your local space, use unityhub reopen this project, and you can hit the breakpoint