Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity refuses to open Visual Studio, opens Monodevelop instead

Discussion in 'Editor & General Support' started by Nithel, Jan 14, 2012.

  1. Nithel

    Nithel

    Joined:
    Feb 22, 2010
    Posts:
    9
    This is really confusing me.
    I've installed Visual Studio 10, and selected it in the "External script editor" option in the preferences. I double-click a script, and the little "Opening visual studio" loading bar pops up. It finishes loading, the loading bar closes and.... Monodevelop opens. What?
    I've tried keeping Visual Studio open in the background, but it still opens all the scripts in Monodevelop.
    I've also tried re-installing Visual Studio, and even installing the express edition (Same problem, just without the loading
    bar).
    If I choose another editor, like Notepad++, it opens that just fine.

    Anybody who has had the same issue? Any ideas?
     
  2. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    VS2010 was installed after Unity, and so the registry entries in Unity are no longer present, i.e. pointing at VS2005 which is no longer available, or were never set up properly because no VS was ever installed.

    Sometimes you can fix it directly. Close Unity, then open the .sln for your Unity project directly into VS2010 by double-clicking it, then selecting Save All. Then exit VS2010 and restart Unity.
     
    Last edited: Jan 14, 2012
  3. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    Have you tried re-installing Unity after installing Visual Studio?
     
  4. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    I think I was implying that in my first sentence but never stated it specifically. Well caught.
     
  5. Nithel

    Nithel

    Joined:
    Feb 22, 2010
    Posts:
    9
    Thanks for the replies.
    I tried doing like your said, opening the project in visual studio and saving it again. I also just tried re-installing Unity and starting with a new project, but no luck.
    Any other ideas?
     
  6. reallyjoel1

    reallyjoel1

    Joined:
    Feb 2, 2009
    Posts:
    19
    I have the same problem, and to add confusion NOTHING HAPPENS if I double-click the .sln in the explorer. I can open the .sln from within VS2010, but two of the projects are unrecognised (.unityproj)

    So the problem might be connected with the fact that VS won't even start from double-clicking the .sln?
     
  7. thargy

    thargy

    Joined:
    Jun 24, 2012
    Posts:
    6
    Yeah I've tried this in VS2008, VS2010 and VS2012. The sln contains .unityproj files like reallyjoel mentions, these are not recognised by Visual Studio so even though it will open the solutions if forced to do so, it will not 'upgrade them' to full VS solutions, and as such will refuse to open them automatically. At least I think that's what the issue is, so even though Unity says it's opening in Visual Studio, it pops up in Mono Develop anyway.

    Has anyone got any ideas?
     
  8. thargy

    thargy

    Joined:
    Jun 24, 2012
    Posts:
    6
    OK, so here's the solution...

    Unity now keep two solution files - Project.sln and Project-csharp.sln. (Where Project is your project name obviously).

    The first solution file is the main one used by unity and contains the custom project type (unityproj), the second solution file does not contain the unity project files - which bug VS.

    So to get this working, open Project-csharp.sln in VS first (whilst Unity is closed). Do this by right clicking and using 'Open With' or by loading Visual Studio and using the file menu. Once loaded, click 'Save All' and close the solution. This will add a .suo file showing VS now recognises the solution and has added user options.

    When you load Unity and double click on a C# script (only) it will load the CSharp projects into VS for you instead of mono develop.
     
    zeb33 likes this.
  9. RyuMaster

    RyuMaster

    Joined:
    Sep 13, 2010
    Posts:
    468
    Thargy, while you are right, I can't still get yoru solution to work. Unity team, please do something about unityproj fils, as Vs2010 fails to load files with them
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    For me this worked only to a degree.

    Unity will only open the files in Visual Studio successfully only if Visual Studio is currently running and the Project-csharp.sln is currently open in Visual Studio. If those two conditions are not met, it opens in MonoDevelop.

    Seems rather a cludge to me, and rather annoying as I switch between my precompiled DLL solution and the Unity project solution a lot.
     
  11. Brotherhood

    Brotherhood

    Joined:
    Dec 8, 2012
    Posts:
    73
    Please excuse me for bumping a dead topic, but I've only recently started having this issue after upgrading to the latest Unity release ( 4.0.1f2 ?).
    I've tried using the aforementioned solutions but I'm still having MonoDevelop launch regardless. Has anyone successfully figured out how to get it working properly again?

    Edit:
    To anyone else still having this problem, after a lot on nonsense, I managed to get it working again by un-checking Editor Attaching in the Preferences.
     
    Last edited: Feb 20, 2013
  12. Krummelz

    Krummelz

    Joined:
    Feb 20, 2013
    Posts:
    3
    I'm having the same problem, after upgrading to Unity 4.1.3f from the previous one (4.0.1 or 4.0.2 I think). I started out with this issue on the last version, and somehow managed to fix it. (I can't remember what finally did the trick) But now that I have upgraded, this problem is back again. I also have VS2012 selected in the External Tools section of the Preferences. My Assets menu, however, says "Sync MonoDevelop Project"? I do recall previously renaming the MonoDevelop folder in the Unity installation directory. I did this again, and now it loads VS2012 when I double-click a script in Unity, but it doesn't load the Mono assemblies into a solution, it just opens the file on its own. None of the other solutions above worked for me. MonoDevelop is like the crazy ex-girlfriend who won't let go.
     
  13. Nems

    Nems

    Joined:
    Jul 18, 2011
    Posts:
    65
    I have finally found a solution !
    I hope it will works for you...

    a) Create a .bat file with the following command :
    Code (csharp):
    1.  
    2. start "" %*
    3.  
    b) Then place that file in the same folder as Visual Studio IDE executable (should work with any version). For 2010 it's : C:program Files (x86)Microsoft Visual Studio 10.0Common7IDE

    c) In Unity3D, Edit > Preferences... > External Tools In the "External Script Editor" dropdown, select "Browse..." and locate the BAT file created in step a).

    d) To edit a script, first run the "Sync MonoDevelop Project" (right-click in the Project pane) to open VS, then do as usual.

    e) Say hello to a real IDE and say goodbye to MonoDevelop (almost because you'll need it for debug).
     
    Last edited: Aug 23, 2013
  14. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    When choosing your editor, you can also choose "Custom" and point to:

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe

    In my case I switched to using Visual Studio 2013 Preview which was installed after Unity and it works fine for me.
     
  15. Statement

    Statement

    Joined:
    Oct 18, 2010
    Posts:
    18
    Thanks thargy and Nems!

    The .bat file works - but when double clicking a log entry for a compile error, it will only jump to the file but not the correct line in the file.

    The .suo file generation worked only as long as Visual Studio already was running, but it jumps to the correct line in the correct file.

    If it helps anyone find a pattern, my background is that I have installed/uninstalled several versions of Visual Studio (Express/Pro/2010/2012) and at some point it got borked. Uninstalling the redundant versions so I only have 2012 Pro, and resetting the editor preferences to point to my single install of VS 2012 Pro is not enough.

    I'll stick with the .suo trick (double click a script file, close mono develop, close unity, open the sln file with VS2012 Pro, save so the suo file is generated, start Unity, now double clicking works) as it only requires me to generate the suo once (given I don't delete it) and only have to open the project with Visual Studio before I want to access any code with it. After that, double clicking any scripts or double clicking any errors will work as expected.
     
  16. quetzy

    quetzy

    Joined:
    Mar 8, 2014
    Posts:
    1
    Sorry to resurrect this but I just ran into this same problem and none of the above worked for me.
    What did though is - running Unity as an Administrator (problem with starting VS from Unity was that UAC required permission to run it and Unity just dismissed it and ran MonoDevelop instead).
     
  17. shopguy

    shopguy

    Joined:
    Jan 12, 2013
    Posts:
    282
    Have similar issues. I've tried uninstall + reinstall of the latest version of Unity, and I already have VS 2012 Pro installed, and still same problem. Selecting "Sync Mono Develop Project" in Unity, or trying to open any CS files just flashes the MonoDevelop splash screen for half a second then "nothing happens". No errors in the Unity console or otherwise, very annoying. Checked the registry settings under HKEY_CURRENT_USER\Software\Unity Technologies, and the path to the script editor is correct (points to devenv.exe), I even tried changing the / to \ since I'm on Windows not Mac/unix, no luck.

    I can run VS just fine... and I don't even care if I can't open it from Unity, but how do I at least get Unity to build the solution file? I've tried reinstalling Unity with and without Mono installed, same thing either way, and I've tried changing the preferences in Unity to Mono Develop, then back to Visual Studio 2012, and also tried using the Browse... button to select devenv.exe manually.

    I've tried running Unity with elevated permissions (UAC), and without.

    I do run using a non-admin account, under Win8, as is recommended by Microsoft for security reasons and because this is a family/shared PC. Guess I'll try changing my account to admin and reinstall yet again, see if that helps, but I can't leave it that way. When I install Unity I've been installing from my non-admin account, but when UAC prompts I'll select the admin user and enter the password, not sure if there are known issues with that (that's how I install all of my software, never had problems except with old/legacy apps not designed for Vista+/UAC).

    Edit: Looks like the BAT file trick mentioned here got my SLN files created at least, guess I'll just live with that. Really hope Unity 5 makes improvements in this area, I've installed Unity on 4 or 5 different PCs over the last few years, and not once has the VS integration worked well... which seems kind of silly because all it needs to do is create the SLN files (at the very least that should always work) then CreateProcess or ShellExecute an EXE (should also work at the very least), then not sure what is required for the "open file and go to line number" part, maybe OLE, but even so the first 2 easy parts should always work. Unless I'm missing something, in which case sorry for the rant ;)
     
    Last edited: Mar 30, 2014
  18. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    For what it's worth, I read somewhere that renaming Monodevelop.exe to something else solves the problem. Apparently Unity times out launching VS way too early and defaults to Monodevelop. This solution worked for me. I just renamed it to Monodevelop_Orig.exe.
     
    Alec-Slayden, justinlloyd and pgeedi like this.
  19. pgeedi

    pgeedi

    Joined:
    Mar 19, 2015
    Posts:
    1
    Thanks Noogy, just renaming the monodevelop executable worked for me.
     
  20. kloogens

    kloogens

    Joined:
    Jul 1, 2015
    Posts:
    109
    Me too!!
     
  21. JakubNei

    JakubNei

    Joined:
    Jul 20, 2013
    Posts:
    26
    Running Unity as an Administrator fixed it for me.
     
  22. gouthammannuru

    gouthammannuru

    Joined:
    Sep 9, 2015
    Posts:
    16
    hi every one
    i had the same problem and i broke my head but found the simplest solution

    please follow

    1. Open Unity

    2. Go to Edit (Second Tab)

    3. Click on Preferences (A new Tab will open )

    4. Click on External Tools (Second Option Available)

    5. Choose from the list of options Available

    AND YOU ARE DONE (Make sure your option of the editor is Installed first LOL)
     
    lancelarsen likes this.
  23. Hodgson_SDAS

    Hodgson_SDAS

    Joined:
    Apr 30, 2015
    Posts:
    123
    If you're using Resharper, you need to disable it every time you run VS, then re enable
     
  24. austinIsBoss1178

    austinIsBoss1178

    Joined:
    Nov 26, 2015
    Posts:
    2
    im having the same-ish problem, but backwards... it open visual studio instead op mono develop, idk how to use Visual studio, when i type an input of some kind it says.. NOPE! ONLY ERRORS FOR YOU!
     
  25. Penaranda

    Penaranda

    Joined:
    Dec 6, 2015
    Posts:
    1
    worked for me, on Unity 5.2.3f1 64 bits, thanks :)
     
  26. _secluder_

    _secluder_

    Joined:
    Jun 18, 2013
    Posts:
    10
    I couldn't figure out why one of my projects would open DevStudio and the other one would open MonoDevelop. After trying many suggestions, it turned out that the folder of my project had "c#" in its name. I removed that and it worked!
     
  27. Triariy

    Triariy

    Joined:
    Aug 15, 2013
    Posts:
    1
    Run Unity with admin rights. This may happens when you set devenv.exe process run only with admin rights
     
  28. BlakeLeid

    BlakeLeid

    Joined:
    May 11, 2016
    Posts:
    1
    I had this problem while installing the 5.4 Beta. My solution was the above. Make sure Unity is starting with Admin rights. (Right click shortcut, Properties, Compatibility, +Run this as admin)
     
    nebosite likes this.
  29. PeterMorris

    PeterMorris

    Joined:
    Aug 24, 2016
    Posts:
    4
    I experience this whenever I delete my local files and then check-out from a source control server. To fix it I do this

    1: Try to open a file and let it fail in Mono (this created the SLN file)
    2: Kill Unity
    3: Browse to the SLN file and double-click to open in VS
    4: Save all
    5: Restart Unity and try again
     
  30. nebosite

    nebosite

    Joined:
    Mar 13, 2013
    Posts:
    10
    Ditto. I change unity to start with admin rights and the VS integration worked seamlessly.
     
  31. warpmanih

    warpmanih

    Joined:
    Dec 27, 2016
    Posts:
    1
    Thank You some much. I have tried every other solution, then I saw this one it works beautifully thank you so much!
     
  32. Tijl_Reynhout

    Tijl_Reynhout

    Joined:
    Dec 14, 2016
    Posts:
    1
    That has fixed it for me! thanks!
     
  33. tcook2

    tcook2

    Joined:
    Mar 19, 2019
    Posts:
    1
    go to preferences and under external tools select external script editor and put visual studios