Double clicking a C# script should open Visual Studio

Hi folks,

Unity 4.5.1p1 is out with this bugfix:

Like all great bugs this was not one large bug but 2 or 3 smaller ones masquerading as one big one.
Also, like all great bugs, this did not happen on everyone’s machine.
Because of this what I would like to do is, after 4.5.1p1 is released, try and get a bunch of votes to determine whether I successfully fixed every variant of the bug. Note 4.5.1 aka 4.5.1f3 does not yet have this bugfix.
So once p1 is released please read the options for the poll carefully and pick the answers which matches your situation best. It’s multiple choice so please tick all that are relevant. For science!

Don’t forget to set VS as your External Script Editor in preferences:
1661106--103905--vs2008.png
Very much appreciated folks, and hope to fix some more stuff in the future for you!

Dave

3 Likes

FWIW, I see the release note for p1 says that ‘If Visual Studio is open with another project’ then it’ll still fail. I think that in pretty much every previous situation I’ve encountered this bug (and yeah it’s been pretty frequent), there’s been a devenv.exe running in the background that I’ve had to kill…

That sounds like yet another variant of the bug which I haven’t reproduced or fixed yet.

Ah, interesting. Might have something to do with Resharper being installed…

Also, in the past it’s been 100% reproducible that if Visual Studio is displaying a modal dialog, Unity fails to make it open the project and falls back to MD. Does that sound like one of the fixed cases?

(If that doesn’t sound familiar to you, try these repro steps:

  • Create a project with a script in, double-click the script to go to VS
  • In VS, add a new code file
  • Go back to Unity and double-click the new code file
  • VS displays ‘discard project changes?’ dialog. Don’t dismiss it.
  • Go back to Unity and add a new code file, double-click it
  • Unity attempts to talk to VS, fails, opens MonoDevelop)

Ah, good repro steps, I’ll add that to the fogbug notes on Monday.

One of the things is that if the VS launch fails for any reason, the code is designed to “run home” to MonoDevelop as a fall back instead of actually reporting the error to the user. This makes sense from a “I just want to see the script dammit” pov, but feels kind of annoying if you are trying to diagnose a problem with VS launching.

It might make sense for me to at least add some debug logs so we can differentiate all the different failure cases, and possibly disable the MD fallback.

Hey remember I said this bug was actually 2-3 smaller bugs? Make that 5-6 :wink:

Out of curiosity, what is the latest version of Unity (free) that allows VS 2008 to open projects correctly? Thought I’d upgrade from 4.1.3f3 and discovered this unfortunate bug in 4.5.1. Just trying to avoid another 1+ GB download. :slight_smile:

Can you try 4.5.1p1 and see if it is fixed?
http://forum.unity3d.com/threads/unity-patch-releases.246198/#post-1662438

Downloaded 4.5.1p4 and VS 2008 opened fine. :smile:

Thanks!

Incidentally, I didn’t realize until going to the link you provided that the “p” stood for patch. I was thinking it stood for “pro”.

Copied from other thread:http://issuetracker.unity3d.com/issues/double-clicking-a-c-number-script-will-open-monodevelop-instead-of-visual-studio
I am still seeing this issue on 4.5.2f1 using VS2012 and Windows 8 (Surface Pro 2) - Does anyone have a fix for this. Is there a timeout on how long it takes VS to open and if it fails to open in that time then opens MonoDevelop… ?? Is there a way to change that…

Tryed
renaming executables… Failed
reinstalling and installing in different orders… Failed
restarting… Failed
creating new project / new solutions… Failed

Hello,

I have upgraded from Unity 4.5.1 and now the problem seems to be worse with 4.5.2f1.

All my projects now refuse to open Visual Studio 2010.

Older versions of Unity would at some point open Visual Studio 2010 on the second try when clicking on a C# script.

I am using Visual Studio Professional 2010.

I’m having the same issues with Unity 4.5.2f1 and VS2013 Premium. I’m running also VS2012 Premium and have the same problems. Unity starts always VS2010 Shell with the message that I dont have a license.

I tried to change registry keys, changed default settings for *.cs, *.sln, *.cproj files etc. Without any success.

It only works when I start the solution manually in VS2013.

As discussed in the issue tracker for this problem, I have made some changes to improve the behavior in 4.5.3p1.

@superpig : I believe these changes will improve the situation that you reported, although it will not be fixed entirely. In your last step (Unity attempts to talk to VS, fails, opens MonoDevelop), now a new session of Visual Studio will start instead of MonoDevelop. Unfortunately, we can’t do much about the Visual Studio session that has a modal dialog. When that is the case, any communication with Visual Studio from the Unity editor will be rejected by Visual Studio, so we can’t even determine if a given Visual Studio instance is the one with the Unity solution currently open. So I think our best option is simply to open a new instance of Visual Studio. This should be an improvement over the existing behavior though.

@philippen : I wasn’t able to reproduce your specific problem, but I think the additional information written to the editor log in 4.5.3p1 will help. If you have a chance, please give it a try when it is available and let me know if the problem still occurs. If so, the information in the log file will likely help us to track down the cause of the problem.

1 Like

@skuami : You are likely seeing Unity fall back to the system default editor because Visual Studio 2013 is busy immediately after it is started. Please try 4.5.3p1 when it is ready and let me know if the problem persists.

Thanks Josh!

Here’s an other hint for trouble shooting:

I just installed the UnityVS tools (it is free since MS bought the company behinde the tools) and it works again. Now I am able to double click on a script file in unity and it opens visual studio correctly.

I still run Unity 4.5.2.f1 and VS2013 Premium.

In other words, the UnityVS tools solved my VS problem. :wink:

for what it’s worth, I had the same issue after cleaning my registry, but I realized that it still works, I just needed to run Unity in administrator mode. Using Windows 7 and an up-to-date Unity. Hope this helps other people as well :slight_smile:

1 Like

@skuami : I’m glad to see that UnityVS worked for you. I suspect that this works around the problem because UnityVS adds a new entry in the External Script Editor preference (UnityVS.OpenFile). Please let us know if you run into problems in the future.

I started experiencing this issues with version 4.6.0b20 and VS 2010 Ultimate. Everything has been working fine for months and out of the blue it just started saying it was opening VS and opened Mono Develop instead.

I found if I open the project in VS 1st it will open the scripts in VS like normal, but if VS is not open or the project is not already open in VS it will not.

This is happening again in 4.6

Can you provide the Editor.log file when this problem happens here or submit a bug and let me know the bug number? We now have a good bit of logging for these cases in the Editor.log. That should help us track down the cause of the problem. Thanks.

As I mentioned to Dagra, please provide the Editor.log or submit a bug when this happens. With the logging we have enabled we should be able to find and correct the cause of the problem. Thanks.