Unity refuses to open Visual Studio, opens Monodevelop instead

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?

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.

Have you tried re-installing Unity after installing Visual Studio?

I think I was implying that in my first sentence but never stated it specifically. Well caught.

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?

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?

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?

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.

1 Like

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

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.

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.

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.

I have finally found a solution !
I hope it will works for you…

a) Create a .bat file with the following command :

start "" %*

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

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.

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.

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

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 :wink:

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.

3 Likes

Thanks Noogy, just renaming the monodevelop executable worked for me.

Me too!!