Search Unity

[SOLVED] Can't attach to Unity from VS2017

Discussion in 'Code Editors & IDEs' started by qkjosh, Jul 24, 2018.

  1. qkjosh

    qkjosh

    Joined:
    Nov 29, 2015
    Posts:
    33
    I'm not sure what has happened, but today I've found myself unable to Attach to Unity to do any debugging from Visual Studio. I can build the game from Unity without errors, build the entire solution in Visual Studio without errors, but when I try to attach, I get "The operation could not be completed. Unspecified error".

    This is with Unity 2018.2.0f2, Visual Studio 2017 v15.7.5, and VSTU v3.7.0.1. Earlier, I was getting build errors saying that dlls in locations such as Packages\com.unity.textmeshpro\Scripts\Runtime\[example.dll] could not be found, but those errors seem to have gone away (I deleted the solution, temp folder, etc. and had Unity regenerate them, although the folders in Packages are still in fact empty).

    I can attach to Unity with VS 2015 and an older version of VSTU, which leads me to believe this is related to the new structure of the Assembly-CSharp, Assembly-CSharp-Editor, Assembly-CSharp-Editor-firstpass, and Assembly-CSharp-firstpass projects.

    MonoDevelop complains about these projects at startup, saying that it "could not load project 'Assembly-CSharp.csproj' with unknown item type {GUID}". It displays four warnings, one for each project.

    Any idea what's going on here? I've tried debugging various projects and they all fail in similar ways.

    EDIT: Solved it by re-installing Visual Studio and VSTU...
     
    Last edited: Jul 24, 2018
  2. DwarfinChief

    DwarfinChief

    Joined:
    Mar 11, 2015
    Posts:
    3
    I am experiencing something similar. Same Unity and VS versions here.

    When I press "Attach to Unity" in VS an error pops stating
    "The operation could not be completed. Unspecified Error"

    This started when I downloaded Unity 2018. Our entire team is on 2018 now and I cannot go back to 2017.

    I have tried uninstalling/reinstalling VSTU from the VS Installer program, from the extensions add/update screen.
    I've tried reinstalling VS and re-adding VSTU.

    Nothing seems to work.
    I can't even use the normal "Attach to process" option as attaching to unity.exe and/or unityHelper.exe doesn't work.
     
  3. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    I am also now having this exact issue. Cannot attach to Unity and get the same exact error.

    Unity: 2018.2.2f1
    VS: 15.7.6
     
  4. zetaFairlight

    zetaFairlight

    Joined:
    Apr 26, 2018
    Posts:
    14
    Can't Attach, using VS2017 and Unity 2018.2.15f1
     
    terraslate likes this.
  5. kgindemitsoulside

    kgindemitsoulside

    Joined:
    Nov 5, 2018
    Posts:
    3
    This thread is marked as solved. How it was solved?
     
  6. qkjosh

    qkjosh

    Joined:
    Nov 29, 2015
    Posts:
    33
    As far as I can recall, I ended up trying a bunch of things like deleting the solution files and re-installing Unity tools for Visual Studio, and somewhere along the way it sorted itself out. Wish I could be more specific.
     
  7. aaronsmithuk

    aaronsmithuk

    Joined:
    Jul 2, 2016
    Posts:
    2
    I fixed the exact same problem by removing the BitBucket extension for Visual Studio.
     
    hjc_ likes this.
  8. rosco_y

    rosco_y

    Joined:
    Aug 3, 2016
    Posts:
    100
    I have the same problem (on and off.).
    Microsoft Visual Studio Community 2019
    Version 16.1.1
    VisualStudio.16.Release/16.1.1+28922.388
    Microsoft .NET Framework
    Version 4.7.03190

    Installed Version: Community
     
  9. JasonMcEvoyFMR

    JasonMcEvoyFMR

    Joined:
    Apr 3, 2019
    Posts:
    4
    Delete .vs folder worked for me
     
  10. maeleeuxs

    maeleeuxs

    Joined:
    Mar 29, 2020
    Posts:
    1
    Hi, I had this problem today and solved it by reinstalling "Game Development with Unity".
    I got a popup from my firewall this time for allowing Visual Studio 2019 on public or private networks.
    I checked both and now it works.

    The first time it didn't give me any popup or I might have accidentally clicked it away.
    So I think the problem might've been a missing firewall entry.

    I hope this helps.
     
  11. hjc_

    hjc_

    Joined:
    Feb 7, 2020
    Posts:
    1
    Want to chime in and say I hit this issue in VS2019 and tried the above solution and, while uninstalling and reinstalling the "Game Development with Unity" package worked, it only worked for the first restart and stopped working.

    Once I disabled the BitBucket VS extension, everything started working. Seems there's a conflict there.
     
  12. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    522
    I have this issue (VS2019 clean install and unity 2020.1) and I do not use BitBucket or have ever installed it.

    Uninstalling the Visual Studio Tools for Unity package and reinstalling it fixed the problem.
     
  13. elenzil

    elenzil

    Joined:
    Jan 23, 2014
    Posts:
    73
    Same. I'm guessing the problem began when I updated VS2019 to the most recent version.
    No BitBucket involvement.
    As Innovine said, uninstalling and reinstalling the Unity Tools package worked,
    but adding a note that to do this I needed to use the VS Installer to first uninstall the "Game Development With Unity" workflow and then re-install. Perhaps it can be done just via extension manager, but I didn't figure it out.
     
  14. benvancitters

    benvancitters

    Joined:
    Feb 19, 2019
    Posts:
    1
    I got this issue in Microsoft Visual Studio Community 2019 Version 16.7.7 & Unity 2019.3.9 and was able to resolve it by finding and removing the visual studio .suo file which was located under the project root at
    .vs/[projectname]/v16/.suo
     
  15. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    996
    Deleting all the .csproj and .sln files in proj root worked for me. Then in Unity, assets -> open c# project to rebuild.

    Sometimes deleting your debug break points fixes it.

    However, these are all workarounds. This has been a bug for years: Where is QA?
     
  16. vittorioleo82

    vittorioleo82

    Joined:
    Jan 15, 2021
    Posts:
    4
    The problem is due to the wrong startup project. Set as startup your project and it should be work.
     
  17. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    171
    Where is the unity tool package ?
     
  18. Stridemann

    Stridemann

    Joined:
    Oct 12, 2013
    Posts:
    251
    Sometimes that happen for me. Restart of unity+VS doesn't help.
    1. Close VS
    2. Edit->Preferences->External tools - Regenerate project files button
    3. Launch VS and attach. (also check the startup project in vs)
     
  19. WaveRacer

    WaveRacer

    Joined:
    Aug 14, 2014
    Posts:
    1
    Uninstalling the Live Share Visual Studio extension fixed it for me, but I'm not very certain that was the cause of the problem...
     
  20. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    996
    I can confirm I had this issue before that feature even existed. Dates back to.... Unity 5?

    I still get it in 2020.1. it's causes by breakpoints, weirdly. I've had a 100 percent success rate with simply deleting breakpoints then trying again. You don't even need to restart anything. It appears to be a Tools for Unity (Microsoft) bug.

    Although it's a Microsoft bug, it should be Unity's responsibility to reach out to them for a fix. It's only been years.
     
  21. NEVER-SETTLE

    NEVER-SETTLE

    Joined:
    Apr 22, 2018
    Posts:
    30
    Same problem here.

    Reinstalling helped

    Why pay QA when you can have free QA from your customers? That's the Microsoft motto. Just look at Win 10.
     
  22. mastloui

    mastloui

    Joined:
    Sep 3, 2020
    Posts:
    5
    Worked for me as well!
     
  23. Majestijn

    Majestijn

    Joined:
    Jan 24, 2017
    Posts:
    11
    This is still an ongoing issue for me. Tried everything to no avail:

    • Re-install VSTU
    • Use different versions of VS (2019, 2022)
    • Re-install VS
    • Regenerate project files
    • Delete .sln and .vs folders
    • Disabled firewall

    Nothing worked for me. Any other suggestions? Maybe a Unity engineer could take a look at this?
     
  24. tabulatouch

    tabulatouch

    Joined:
    Mar 12, 2015
    Posts:
    23
    Please... give us a LOG file to debug the debugger not attaching :(
     
  25. kulbabix

    kulbabix

    Joined:
    Nov 3, 2020
    Posts:
    1
    What has worked for me:

    I've selected Attach Unity Debbuger in the Debug menu;
    upload_2022-4-8_18-37-27.png

    After that a Windows Security Alert popup with Windows Firewall appeared.
    I have applied Allow access.
    After that attaching for Unity has started working again.

    Hope it helps someone.
     
  26. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    It seems this operation is the new "Attach to Unity" workflow going forward in Visual Studio 2022. When clicking on the Attach Unity Debugger, it will launch a new dialog, asking you to pick and choose which Unity process you wished to debug.

    What you want to do is to pick the Unity process that has your project name next to it. All other processes are either Unity Hub, or some other Unity background process.

    For me, I picked out my project, and I can debug my script as normal. What I don't know enough about is, why we need to use this new workflow and not have the old Attach to Unity debug operation be used for this?

    If anyone knows, please post below.
     
    ProdGema likes this.
  27. The_MAZZTer

    The_MAZZTer

    Joined:
    Sep 19, 2019
    Posts:
    3
    I had this issue. Deleting the .vs folder, .vsconfig file, obj folder, and the csproj and sln files, then using the "Open C# Project" menu option from Unity to regenerate them fixed this issue in Unity 2021 for me.
     
    ilkerulger likes this.
  28. ilkerulger

    ilkerulger

    Joined:
    Jul 26, 2021
    Posts:
    1
    after upgrading to 2021.3.11f1 version I faced the same problem and this resolved it.
     
    rosco_y likes this.
  29. adasroky

    adasroky

    Joined:
    Nov 10, 2020
    Posts:
    3
    This also worked for me. I have like no idea why, but after I disabled Live Share it just connected
     
  30. RedGlow82

    RedGlow82

    Joined:
    Nov 22, 2013
    Posts:
    8
    This was the only solution that worked for me.