Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

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

Discussion in 'External Tools' 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:
    7
    I have the same issue :(
     
  3. Democide

    Democide

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

    Nickromancer

    Joined:
    Jul 31, 2016
    Posts:
    22
    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:
    548
    Same issue.
     
  6. fatboynotslim

    fatboynotslim

    Joined:
    Aug 19, 2013
    Posts:
    7
    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. ShikenNuggets

    ShikenNuggets

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

    TenKHoursDev

    Joined:
    Nov 9, 2014
    Posts:
    1,114
    I found that @ShikenNuggets solution worked! Definitely try that!
     
  9. mr_president

    mr_president

    Joined:
    Jun 28, 2015
    Posts:
    5
    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:
    2
    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!
     
  11. CaptainKirby

    CaptainKirby

    Joined:
    Dec 12, 2011
    Posts:
    33
    @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:
    10
    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:
    880
    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:
    638
    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:
    45
    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:
    11
    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:
    45
    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:
    274
    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.
     
  20. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    880
    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.
     
  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:
    3
    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:
    42
    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:
    6
    Last edited: Oct 16, 2019
  27. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    42
    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:
    42
    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:
    3
    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