HOWTO: Diagnose a Visual Studio startup hang problem

For the most part, I love Visual Studio, but some weeks I hate it very deeply :-). In its current incarnation VS 2015, but also from its origins in VS.NET 2002, it is such a huge piece of software, composed of so many parts, that it’s quite fragile and not very resilient. Microsoft knows it and so it recommends to install betas and previews on non-production machines, that is, on virtual machines. Also, it is painfully slow to install unless your computer is fast and has a SSD. The other day I created a Hyper-V virtual machine on the Surface 4 Pro that I use at work to install VS “15” Preview 5. I don’t know how it happened exactly: I think that I deleted an existing Hyper-V virtual machine with the Visual Studio emulator for Android that I installed days ago for a Xamarin course and that I had to uninstall because in turn I had uninstalled Xamarin because it slowed my VS 2015 startup quite noticeably and Xamarin projects took minutes to create using the New Project menu (I want to love Xamarin, so I will use Xamarin Studio on my Mac). Anyway, my Surface laptop suffered a horrible BSOD at startup (APC_INDEX_MISMATCH or similar).

Update Nov 9, 2016: The BSOD crash APC_INDEX_MISMATCH was caused by an update to the Trend Micro Antivirus+ 2016. The solution is to update to Trend Micro Antivirus+ 2017, as explained in their web page Getting stuck on Windows Startup Repair after updating Trend Micro Security.

I could only recover it going back to a restore point. Visual Studio 2015 got an inconsistent state as a result. So I uninstalled it. And I uninstalled VS 2010 too, which anyway was suffering a crash for months each time I tried to show the properties page of any project. And I went to the Control Panel and I removed tons of stuff that were related to Visual Studio. But I forgot to delete the Visual Studio entries in the Registry and remaining folders on disk. When I reinstalled VS 2015 and launched it, the main window did not respond to mouse clicks, only a “ding” sound, as if it was shown an invisible modal dialog. So I uninstalled VS 2015 again and this time I deleted registry entries and remaining folders on disk. After reinstallation, just after the splash screen I got this empty modal dialog (and the main screen was not shown):

vs2015hang

I tried to uninstall, repair, execute devenv.exe with all kind of “reset” flags, etc. to no avail. Since the alternatives are to reinstall Windows, or to give up VS 2015 and wait for the RTM of next VS “15” version, I decided to troubleshoot the problem. There are at least three approaches to diagnose Visual Studio startup problems:

  • The first one is to use the own activity log of Visual Studio. To use this approach, click the Start button of Windows, type “Developer” and the result should appear in the first positions:

developercommandprompt

At the Developer Command Prompt, type:

devenv.exe /log C:\Users\<your user>\Desktop\MyVSLog.xml

developercommandpromptcommand

That will launch Visual Studio and will create the log on your desktop (by default Visual Studio would create it on another location). Close or kill Visual Studio and two files should appear on your desktop: MyVsLog.xml and ActivityLog.xsl.

The ActivityLog.xsl file is a XML stylesheet that allows the XML file to be viewed nicely formatted on a browser (the XML file has this line for this magic to work: <?xml-stylesheet type=”text/xsl” href=”ActivityLog.xsl”?>). In the output, focus first on red items:

connecteduserpackagefailedtoload

So, in my case the problem is:

Could not load file or assembly ‘Microsoft.VisualStudio.Services.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified.
  • The second approach is to use the Assembly Binding Log Viewer (aka “fuslogvw”). This tool applies to any application that uses .NET (not only to Visual Studio) and allows you to know which assemblies couldn’t be loaded and which paths were probed. To launch it, open the Developer Command Prompt of the previous approach but this time with admin rights (right-click “Run as administrator”). Then click the Settings button:

assemblybindinglogviewersettings

If the radiobuttons are disabled it means that it wasn’t launched with admin rights. Select the “Log bind failures to disk” and “Enable custom log path” settings, typing as custom log path “C:\Users\<your user>\Desktop”. Click the OK button, launch Visual Studio, and close or kill it once the error has happened. You will get some assembly binding failures:

assemblybindinglogviewerfailures

Important: do not forget to click the Settings button again and select the “Log disabled” setting.

In my case, I got binding failures  for the assembly:

Microsoft.VisualStudio.Services.WebApi, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

and:

Microsoft.VisualStudio.Services.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Clicking on any item of the list opens your browser with an .htm file with the details of the failure, the folders where it was searched for, etc.:

assemblybindinglogviewerfailuredetails

  • The third approach is using the Process Monitor tool by Microsoft (formerly by Sysinternals). This approach can be used with any application, managed (.NET- based) or native. It allows you to find failures locating files or registry entries. However, the volume of information can be very big, so it should be used as a last resort. To use it, when launched configure the filter to monitor only devenv.exe:

processmonitorfilter

And in the output you need to dig into the results finding PATH NOT FOUND or similar errors for files that never appear as SUCCESS:

processmonitorfilenotfound

So, using any of these approaches I know now that my Visual Studio installation doesn’t have the assemblies Microsoft.VisualStudio.Services.Client.dll and Microsoft.VisualStudio.Services.WebApi.dll. I haven’t solved the problem yet (the repair option of Visual Studio doesn’t reinstall them) but at least I have more information.

6 thoughts on “HOWTO: Diagnose a Visual Studio startup hang problem”

  1. Same here. Frantically removed nearly everthing that has “14.0” and “Visual Studio 2015” in its name, removed registry keys, tried installing Visual Studio using the iso file countless times, checked the sha-1 checksum of the file and found out it was perfecly valid, but gave up and tried the web installer anyway. Nothing (reinstall, repair launching using flags) helped. Have you found any solutions?

    1. Nope. I was unable to recover VS 2015. In my case it is convoluted because of the fact that my Surface laptop crashes from time to time at boot time and I need to go back to a restore point in the past, which destroys any fix that I could have found. So, I am waiting for VS “15” to become RC or RTM to reinstall the whole laptop.

  2. So I’ve been experiencing this exact same issue. I had tried literally everything and was about to reinstall windows, when I got around this issue.

    Thanks to your debugging tools in this post I was about to figure out which assemblies I was missing, I would then go ahead and manually download the dlls and place them in the assemblies folders.

    I then eventually got VS to start but came across a few more errors. I eventually got it working enough where the rest of the errors don’t affect my everyday tasks and I can actually finally use VS

    Although it working, this isn’t a good solution and still am considering reinstalling windows.

    Cheers

    1. Hi Csaba Torda,

      How long does it takes for the whole uninstallation process to be completed using this tool?

      I just started using this today around 9.50am and still in progress up to now 10.09am.

  3. I tried virtually all of the suggested fixes… my head was spinning.

    For me the problem ended up being more of a connect the dots thing. Here is my tale of woe as documented in my daily scratchpad.

    What an incredible pain in the you know what!!! I think I finally figured out the problem (VS2015 show splash screen and then stops).

    See the machine.config setting… legacyCasPolicy.

    A couple weeks back, I began working on a ticket for a bug in a legacy Windows Forms application. The app is pretty old stuff… the app was originally built with VS2008…. I upgraded it to VS2010 about 7 years ago.

    I needed to locate the form that triggered the offending logic and the best way was to get a look at likely form candidates was using the form designer. I discovered that the VS2010 form designer had issues with the DevExpress ActiveX control suite that the app’s forms contained. I wrestled with VS2010 before discovering a workaround… this machine.config setting….legacyCasPolicy. Now… this setting was no panacea. It presented some flaky behavior in VS2010. When toggled on… I could use the forms designer…. but could not get anything to build. When off…I could build… but not view anything in designer. Plus… to toggle the setting…. this also involved stopping/starting VS2010. Ok… clunky… but manageable.

    While trying to solve this issue with not being able to run VS2015…. It occurred to me after literally dozens of cycles of install repair/ retry…. uninstall this or that including VS2015/retry…. that this machine config setting might be playing a role in the inability to run VS2015. Sure enough! I had left the setting toggled on and after turning it off VS2015 ran fine. Now that all my third party tools have been uninstalled and my VS2015 environment basically trashed. I think I can recover…. but WOW! Glad it occurred to me that the dots might connect.

Comments are closed.