Search Unity

The breakpoint will not currently be hit. Unable to find a corresponding location

Discussion in 'Code Editors & IDEs' started by nventimiglia, Apr 7, 2017.

  1. nventimiglia

    nventimiglia

    Joined:
    Sep 20, 2011
    Posts:
    153
    • Unable to debug unity project.
    • "The breakpoint will not currently be hit. Unable to find a corresponding location"
    • New Unity project with a single script
    • Runs without errors.
    • Unity 5.60f3, fresh re-install
    • Visual Studio 2017, fresh re-install
    • Experience this in all other projects
    • Noticed Warnings related to test tools.
    • Went through the windows, enabled play mode, everything looks fine there.
    • Please Advise

    Severity Code Description Project File Line Suppression State
    Warning The primary reference "nunit.framework" could not be resolved because it has an indirect dependency on the framework assembly "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5,Profile=Unity Subset v3.5". To resolve this problem, either remove the reference "nunit.framework" or retarget your application to a framework version which contains "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". New Unity Project

    Severity Code Description Project File Line Suppression State
    Warning The primary reference "UnityEngine.TestRunner" could not be resolved because it has an indirect dependency on the framework assembly "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v3.5,Profile=Unity Subset v3.5". To resolve this problem, either remove the reference "UnityEngine.TestRunner" or retarget your application to a framework version which contains "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". New Unity Project

    upload_2017-4-6_17-36-34.png
     
    Gwom likes this.
  2. Gwom

    Gwom

    Joined:
    Aug 5, 2015
    Posts:
    21
    I have the same issue :(
     
  3. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Ah yeah, just ran into this too...
     
  4. Nickromancer

    Nickromancer

    Joined:
    Jul 31, 2016
    Posts:
    92
    Same here with that two warnings.

    I installed VS 2015 and then Unity 5.6 on a new PC and got this on my project.

    However, my project can still break during debug as usual.
     
    Last edited: Apr 25, 2017
  5. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Same issue.
     
  6. fatboynotslim

    fatboynotslim

    Joined:
    Aug 19, 2013
    Posts:
    8
    I have Unity 5.6.0f3 and Visual Studio Community 2017 on Windows 10, fresh install of windows and Unity and visual studio.

    Same issue.

    Like Nickromancer, I can still break during debug.

    However I don't like seeing warnings I didn't cause and can't control, and can't be sure won't cause problems at some later stage...

    Does anyone know how to get rid of it?
     
  7. TacticalBlank

    TacticalBlank

    Joined:
    Apr 28, 2014
    Posts:
    1
    I had a similar issue (Unity 5.6.0f3, VS 2017 Enterprise). I was still able to use breakpoints without any problems, but I got those warnings as well.

    Go Project Settings -> Player -> Other Settings and set the API Compatibility level to .NET 2.0 (as opposed to .NET 2.0 Subset). Restart Visual Studio, Clean and Rebuild the solution. This got rid of the warnings for me.
     
  8. Deleted User

    Deleted User

    Guest

    I found that @ShikenNuggets solution worked! Definitely try that!
     
  9. mr_president

    mr_president

    Joined:
    Jun 28, 2015
    Posts:
    23
    Thanks ShikenNuggets, you're a lifesaver. Breakpoints weren't working AT ALL for me and nothing I tried worked until this.
     
  10. Legend_Bacon

    Legend_Bacon

    Joined:
    Jan 19, 2016
    Posts:
    3
    I had this issue as well for about a week before I decided to do something about it.
    What worked for me was to open one of my .cs files in Notepad++, and set the encoding to UTF-8. For some reason, all my files had changed their encoding to UTF-8 with BOM.

    To do this, open one of your .cs files in Notepad++, go under Encoding->Encode in UTF-8. While you're at it, go to Edit->EOL conversion and make sure you have the right platform selected.

    That one file was now fixed for me, and all I had to do was close Visual Studio, open it again, clean and rebuild the solution. It then auto-applied that encoding to all my files, and everything worked again.

    I hope this works for you!
     
    LBPToo likes this.
  11. CaptainKirby

    CaptainKirby

    Joined:
    Dec 12, 2011
    Posts:
    36
    @ShikenNuggets solution worked for me as well! Many thanks.. I could turn it back to 2.0 subset again and it still works :)
     
  12. jschroyen

    jschroyen

    Joined:
    Aug 19, 2015
    Posts:
    22
    This may have also worked for me, mine was already set to .NET 2.0 so I changed it to .NET 2.0 Subset, then back, restarted VS2017, cleaned and rebuilt solution and now my breakpoints are working. It still showed the "The breakpoint will not currently be hit. Unable to find a corresponding location" warning.
     
  13. LHAppri

    LHAppri

    Joined:
    Aug 18, 2017
    Posts:
    20
    I was running, had a breakpoint on Update() with nothing being hit so I came here looking for help. Saw @ShikenNuggets solution & went in to check the setting. Changed it to .Net 2.0 while running & the breakpoint hit immediately!
     
  14. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    Mine was already on .NET 2.0, I started the game up, changed it to subset, then changed it back and it started working.
     
  15. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Confirmed still an issue with Unity 2018 2.6f1 and VS 2015 (latest VSTU). Had to change API Compatibility from .NET 4.x to .NET Standard 2.0.

    This is pretty bad. So we can't debug if we use .NET 4?

    [Edit]: Nevermind, it's still broken... Worked for a single session then broke again even with .NET 2.0

    [Edit]: After setting the scripting backend to .NET 3.5 it started working, but now it freezes randomly every now and then.
     
    Last edited: Sep 6, 2018
    nsfnotthrowingaway likes this.
  16. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    I'm having the same issue with .NET 4. Can't change .NET versions without breaking the project. If I do, the settings window breaks and doesn't display anything until I restore an old copy of ProjectSettings.asset from before I changed the setting. Unity version 2018.3.0b5. Visual Studio 2017 version 15.8.7 (An older thread with similar issues was solved by upgrading to the latest versions of everything). If I use Debug.Break() it makes it pause the preview in Unity, but Visual Studio doesn't pause. If I manually pause VS while Unity is paused at the breakpoint, I just get the No Compatible Code Running page.

    I get the same unable to find a corresponding location error. I've tried various things from different threads, like deleting library files, and meta files, reimporting, cleaning, rebuilding, etc. Has anyone been able to fix this yet?
     
  17. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    Unity 2018.1.0f1, VS 2017 v15.7.6

    Every once in a blue moon, breakpoints will work. But for the most part they do not. Cannot for the life of me figure out the relevant variable. Tried deleting .sln and .csproj files, clean and rebuilding, switching .net api to 2.0 and back to 4.0, checking firewall, closing and reopening unity and visual studio.

    Nothing works

    Edit: Hey guys, one thing to try. I've notice breakpoints work pretty inconsistently with async methods. Try setting a breakpoint further upstream before your async code runs and make sure that's able to hit. If not, clean and rebuild and close and reopen unity
     
    Last edited: Nov 7, 2018
  18. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    In case anyone has my same issue. What fixed it for me was deleting and then undeleting the library folder of my project. I'm not sure why I've read so many times you can safely delete the library folder, it totally messed up my project when I did that - removing every setting in the inspector of every object. I'm not sure if it's just coincidence, but deleting and then restoring from Git didn't work last time I tried this a couple of months ago - but this time I restored from recycle bin and it fixed the issue.

    For the sake of completeness, I'm not sure what step fixed it, but I did reload my project in unity after deleting the library folder, and again after restoring it.
     
    Last edited: Nov 13, 2018
  19. friuns3

    friuns3

    Joined:
    Oct 30, 2009
    Posts:
    307
    The solution is to put in every file breakpoint with partial class. Once it get hit rest files will load.

    Unity randomly picking 1 file with partial class for debug, thats why its sometimes working and sometimes not.
     
    sier_ua, PlanarBit, OnikiKay and 2 others like this.
  20. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I switched to using JetBrains Rider about a year ago, never had an issue since.
     
  21. kcup024

    kcup024

    Joined:
    Nov 25, 2018
    Posts:
    3
    Using partial classes with 2018.3.4f1. THIS is the only thing that helped within this thread (in my case).
     
  22. corretjerdev

    corretjerdev

    Joined:
    May 29, 2019
    Posts:
    1
    You can get the same breakpoint issue if you try to debug a script that hasn't been attached to a game object. This happens to me quite often and usually takes me about 2 hours to notice I forgot to attach the script to a game object.
     
    FiveXGames and vb2019 like this.
  23. jeroen_m

    jeroen_m

    Joined:
    Sep 1, 2017
    Posts:
    1
    Thanks, this fixed it for me too.

    To clarify: if you're tying to place breakpoints in a partial class, Unity will pick one of the partial classes as the debug file, the breakpoints in the other partial class file show the 'breakpoint will not be hit' message. Putting a breakpoint in both the partial class files makes it hit the breakpoints in both files again.
     
    OnikiKay likes this.
  24. 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
     
  25. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    132
    I ran into this issue again today. If *anyone* working at Unity can fix this bug it would be greatly appreciated! It basically makes using partial files impossible. At least if it picked the one with the shortest name? That might help...
     
  26. ARGB32

    ARGB32

    Joined:
    Feb 20, 2013
    Posts:
    15
    Last edited: Oct 16, 2019
  27. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    132
    This is still a bug in 2019.3.0b4. Has any one reported this bug? I can't search on the Issue Tracker as I get an error:
    Authorisation for this request failed. Check your credentials.
     
  28. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    132
    For what it's worth, I just submitted a new bug report and an example for this as it's driving us crazy.
     
  29. RareRooster

    RareRooster

    Joined:
    Apr 17, 2017
    Posts:
    7
    For me, this started happening while I was working on an Editor script. It's a simple script that adds a couple simple menu items to the Unity Editor. It is not attached to any game objects nor is it a partial class. It's a simple, stand alone, static class.

    What finally got everything working again was, I set a break point in a different class that is attached to a game object. I started Unity and VS. Once that break point was hit, I continued execution then activated my custom Editor menu. As soon as I clicked the top level menu, my previously inactive break point suddenly became active and I was able to step through the code.

    I believe that @friuns3 is correct in that the VS Unity debugger is stuck and not attaching to all/correct process. I believe this is a Microsoft bug not a Unity bug. @MostHated pointed out that she has never experienced this bug since switching away from using Visual Studio.

    A good next step would be to remove the Visual Studio Tools for Unity extension from Visual Studio, restart, then add the extension back.

    Good luck everyone!
     
    Last edited: Nov 8, 2019
  30. LBPToo

    LBPToo

    Joined:
    Dec 20, 2018
    Posts:
    17
    I know this was an old post, but I just ran into this issue after updating from 2019.3.xx to 2019.4 LTS and this solution fixed it. Thanks. Legend_Bacon.
     
  31. UDN_1732af66-d409-45ba-80b6-67e19d05edc6

    UDN_1732af66-d409-45ba-80b6-67e19d05edc6

    Joined:
    Apr 10, 2017
    Posts:
    2
    I'm on 2020.1.7f1 and debug in VS does not work for me at all. I've tried the earlier solution which had worked for me in 2019 but it no longer does. No matter what I cannot get breakpoints to work anymore in VS.
     
  32. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Any word on this? Being able to use a debugger is pretty mission critical when it comes to development.
     
  33. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    Hey all, I ran into breakpoints not working in my project because I build my .dlls outside the unity project and copy them in.
    The issue was that unity was not generating .mdb files for the .dlls.

    The solution was to run pdb2mdb against my .dlls. I do this every time my dlls are copied in. Now breakpoints attach every time
     
    jeroen_m and MostHated like this.
  34. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    711
    I just hit the same issue with Unity 2020.3.LTS and VS 2019 and managed to get it working using the following approach...

    1. Close your project in Visual Studio.

    2. In "Unity -> Preferences -> External Tools" make sure "Registry Packages" is ticked (then click Regenerate project files)

    3. On a\the method call in Visual Studio (in your code) select "Go To Declaration (F12)" - This will open the .cs file in the "Project\Library\PackageCache" folder rather than the "Unity\cache\packages" folder.

    4. Set your breakpoint(s) in the newly opened .cs file.

    5. Attach Visual Studio to the Unity Debugger

    6. Start the Unity Player as normal.

    NOTE: I believe the "Visual Studio Tools for Unity" (in Visual Studio) and "Visual Studio Editor" package (in Unity) both need to be installed.

    Good luck!
     
  35. bbjones

    bbjones

    Joined:
    Feb 1, 2016
    Posts:
    85
    Still happening 2021.3.1f1, vs 2019 and 2022

    Tried everything listed in this thread.

    This does keep happening from time to time and my usual solution is to simply make a build of the project.

    But today, nothing is working including reboots, deleting library folder/all cache files, etc etc.

    Even deleted the offending code file and made a new version of it, no luck.

    Other projects debug fine, this one just seems to have become corrupted.

    Now I'm rebuilding the project from scratch as a new project because of wasting way too much time on this bug that has been happening since 2017 and still isn't fixed.
     
    EZaca likes this.
  36. victornor

    victornor

    Joined:
    Jan 17, 2014
    Posts:
    87
    Still not fixed. Great job unity.
     
  37. unity_216D8AAAD7B598506CEA

    unity_216D8AAAD7B598506CEA

    Joined:
    Aug 8, 2022
    Posts:
    4
    +1
    Still not fixed.
    It's a shame.
     
  38. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    We fixed numerous issues regarding this.

    The first thing to double-check:

    - Do you have the latest VS Editor package in your Unity project ? (should be 2.0.20 as of today).
    - Do you have the latest VS2022 ? (should be 17.7.2 as of today) with the Managed Game workload.

    Thanks!
     
  39. taimex

    taimex

    Joined:
    Feb 20, 2022
    Posts:
    13
    Yes... I have VS Editor 2.0.20 and VS2022 17.7.4 and VS Tools for Unity 17.7.0

    I've deleted ALL built files in Unity that I can find, restarted computer, reloaded Unity with project, Attatch to Unity w/ and w/o Unity in Play mode... Still happens. Downgraded Unity to 2022.3.10f1... Still happens.
    Can't debug my project!!!

    I'll send it to you if you want?
     
  40. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    106
    Hi Sebastion,

    As of late, whenever I shutdown the workstation for the night, the next morning I'll almost always have to delete the Library folder and rebuild it, to get debugging working. With our project, it's almost a half hour wait every time, even with my project on a Samsung 990 Pro SSD (not bragging, just saying we can't get much faster).

    Unity 2021.3.30f
    Visual Studio Editor package 2.0.21
    VS Community 17.7.4

    upload_2023-10-4_12-34-16.png

    upload_2023-10-4_12-29-31.png
    upload_2023-10-4_12-29-58.png

    Not sure if it matters, but there's a version discrepancy between the VS Community edition I'm using, and the one in the Unity dropdown.

    But regardless of the discrepancies, deleting and rebuilding the Library folder fixes the issue for the day. I have a sneaky suspicion it's the "Artifacts" folder which is the culprit, but that's the folder that I'd prefer not to have to rebuild every day (35GB Artifact, and a 65GB Library folder). Is there anything more specific (smaller) you could suggest I delete to get things rolling again? I've tried deleting the solution and project files, and rebuilding the project solution files through Unity, with no luck.

    11th Oct : @sailro Hi Sebastion, any response to this? Thanks.
     
    Last edited: Oct 11, 2023
  41. Ibris77

    Ibris77

    Joined:
    Mar 25, 2024
    Posts:
    2
    Any update on this? What I have is:


    1. When I Open File-> Build Settings in Unity, I get the Build Settings dialog where I have:
    -Development build
    - Script debugging
    - Wait for managed debugger
    ticked.
    If I click on Build and Run on the same dialogue - it generates an executable file which and runs it as well.
    It then waits for the VS 2022 debugger to start.
    But in VS 2022 I still have a tooltip next to be breakpoints saying: "The breakpoint will currently not hit. No symbols are loaded for this document"

    Also, the Symbols for Assembly-CSharp.dll I am trying to debug are loaded in Visual Studio if I check the Modules tab.
    I have VS Editor 2.0.20 and VS2022 and VS 2022 is linked and VS Editor recognized in the External Tools Preferences...

    @sailro any recommendations on how to address this? Also, removing Library folder as suggested above doesn't help in my case.
     
    Last edited: Apr 1, 2024
  42. Saeed-Barari

    Saeed-Barari

    Joined:
    Jul 12, 2021
    Posts:
    56
    have you tried using different API Compatibility Level? restarting Visual Studio and opening it through Unity? and, weird but Visual Studio has a problem where if you change the solution explorer mode from project based to file based, it'll break connection with Unity.

    These are just 3 suggestions from someone who has had a lot of problem with Visual Studio, but I personally haven't seen the exact problem in the 2023 ver. , so these are not guaranteed to work.
     
    Ibris77 likes this.
  43. Ibris77

    Ibris77

    Joined:
    Mar 25, 2024
    Posts:
    2
    Did change the API Compatibility from .NET 2.1 Standard to .NET Standard, which is 4.x I think. Didn't change anything. But when I re-build the app and then run it with the option to wait for the debugger to connect then at least the breakpoint looks fine (without the error message).

    It doesn't get hit though even though the message from the Debug.log appears in the Unity command prompt when running from the the Unity Editor, so I know that that line is executed.

    But it is one step forward I suppose.

    Debug.log works consistently. Breakpoints still don't work. Will try to work that way for now perhaps will step on solution at some point.
     
    Last edited: Apr 2, 2024
    Saeed-Barari likes this.