In case you did not notice, Microsoft released Visual Studio 2015 Update 3 a couple of days ago. I immediately jumped in because I have high hope for better stability – VS2015 update 2 has been crashing more open than I would like.
When I updated my VS on my work computer, all went well and it worked right after that without any problem. However when I finally updated my VS on my home computer, problem appears. Everytime I try to open a solution, it crashes! Rendering my VS2015 totally useless. It’s not a problem I can ignore, and I would avoid reinstall it, unless it’s the last resort.
Digging in the event viewers shed a light on what is wrong:
Application: devenv.exe Framework Version: v4.0.30319 Description: The application requested process termination through System.Environment.FailFast(string message). Message: Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService". ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.Metadata, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.InitializeDisplayAndId() at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.get_Id() at Microsoft.CodeAnalysis.Diagnostics.HostAnalyzerManager.CreateAnalyzerReferencesMap(IEnumerable`1 analyzerReferences) at Microsoft.CodeAnalysis.Diagnostics.HostAnalyzerManager..ctor(ImmutableArray`1 hostAnalyzerReferences, ImmutableArray`1 hostAnalyzerPackages, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource) at Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzerService..ctor(IDiagnosticUpdateSourceRegistrationService registrationService, IEnumerable`1 asyncListeners, IWorkspaceDiagnosticAnalyzerProviderService diagnosticAnalyzerProviderService, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource) --- End of inner exception stack trace --- at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveToState(PartLifecycleState requiredState) at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose() at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.<>c__DisplayClass15_0.<GetExportedValueHelper>b__0() at Microsoft.VisualStudio.Composition.DelegateServices.<>c__DisplayClass2_0`1.<As>b__0() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.<>c__DisplayClass15_0.<GetOrderedAnalyzers>b__0(Lazy`2 p) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items) at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource](IEnumerable`1 items) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.GetOrderedAnalyzers(Registration registration, IEnumerable`1 providers) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor.GetActiveFileIncrementalAnalyzers(Registration registration, IEnumerable`1 providers) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator.IncrementalAnalyzerProcessor..ctor(IAsynchronousOperationListener listener, IEnumerable`1 analyzerProviders, Registration registration, Int32 highBackOffTimeSpanInMs, Int32 normalBackOffTimeSpanInMs, Int32 lowBackOffTimeSpanInMs, CancellationToken shutdownToken) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.WorkCoordinator..ctor(IAsynchronousOperationListener listener, IEnumerable`1 analyzerProviders, Registration registration) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.Register(Workspace workspace) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.StartSolutionCrawler() at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2.Initialize() at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.Initialize() Stack: at System.Environment.FailFast(System.String, System.Exception) at Microsoft.CodeAnalysis.FailFast.OnFatalException(System.Exception) at Microsoft.CodeAnalysis.ErrorReporting.FatalError.Report(System.Exception, System.Action`1<System.Exception>) at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.Initialize() at System.Lazy`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].CreateValue() at System.Lazy`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].LazyInitValue() at System.Lazy`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Value() at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService+WorkCoordinator+IncrementalAnalyzerProcessor+<>c__DisplayClass15_0.<GetOrderedAnalyzers>b__0(System.Lazy`2<Microsoft.CodeAnalysis.SolutionCrawler.IIncrementalAnalyzerProvider,Microsoft.CodeAnalysis.SolutionCrawler.IncrementalAnalyzerProviderMetadata>) at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() at System.Linq.Buffer`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>) at System.Linq.OrderedEnumerable`1+<GetEnumerator>d__1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext() at System.Linq.Buffer`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>) at System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>) at System.Collections.Immutable.ImmutableArray.CreateRange[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>) at System.Collections.Immutable.ImmutableArray.ToImmutableArray[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<System.__Canon>) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService+WorkCoordinator+IncrementalAnalyzerProcessor.GetOrderedAnalyzers(Registration, System.Collections.Generic.IEnumerable`1<System.Lazy`2<Microsoft.CodeAnalysis.SolutionCrawler.IIncrementalAnalyzerProvider,Microsoft.CodeAnalysis.SolutionCrawler.IncrementalAnalyzerProviderMetadata>>) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService+WorkCoordinator+IncrementalAnalyzerProcessor.GetActiveFileIncrementalAnalyzers(Registration, System.Collections.Generic.IEnumerable`1<System.Lazy`2<Microsoft.CodeAnalysis.SolutionCrawler.IIncrementalAnalyzerProvider,Microsoft.CodeAnalysis.SolutionCrawler.IncrementalAnalyzerProviderMetadata>>) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService+WorkCoordinator+IncrementalAnalyzerProcessor..ctor(Microsoft.CodeAnalysis.Shared.TestHooks.IAsynchronousOperationListener, System.Collections.Generic.IEnumerable`1<System.Lazy`2<Microsoft.CodeAnalysis.SolutionCrawler.IIncrementalAnalyzerProvider,Microsoft.CodeAnalysis.SolutionCrawler.IncrementalAnalyzerProviderMetadata>>, Registration, Int32, Int32, Int32, System.Threading.CancellationToken) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService+WorkCoordinator..ctor(Microsoft.CodeAnalysis.Shared.TestHooks.IAsynchronousOperationListener, System.Collections.Generic.IEnumerable`1<System.Lazy`2<Microsoft.CodeAnalysis.SolutionCrawler.IIncrementalAnalyzerProvider,Microsoft.CodeAnalysis.SolutionCrawler.IncrementalAnalyzerProviderMetadata>>, Registration) at Microsoft.CodeAnalysis.SolutionCrawler.SolutionCrawlerRegistrationService.Register(Microsoft.CodeAnalysis.Workspace) at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.StartSolutionCrawler() at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Initialize() at Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage.Initialize() at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider) at Microsoft.VisualStudio.Shell.Interop.IVsUIDataSource.Invoke(System.String, System.Object, System.Object ByRef) at Microsoft.Internal.VisualStudio.PlatformUI.DataSource.Invoke(System.String, System.Object, System.Object ByRef) at Microsoft.VisualStudio.PlatformUI.VsCommand.Execute(System.Object) at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean) at System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
So System.Reflection.Metadata, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ was missing.
But why? and missing from where? A quick search shows that it was used for Roslyn, and dnx uses version 1.1. Visual Studio 2015 also crashes if I try to open Tools => Text Editor => C# => Advanced, where the Roslyn options are. So the problem was Roslyn unable to load an assembly it needs, then the entire VS crashes. Lame!
It seems unable to just reinstall Roslyn alone, so my best bet is to put the correct System.Reflection.Metadata version … somewhere. It’s not clear that where should it be – so I should put it in the most common place – the GAC – Global Assemblies Cache.
This is an attempt to fix:
First, I need to have the assembly. This will require nuget 3.x to run, so you can download the latest version (3.4.4 at this time of writing) from here.
nuget install system.reflection.metadata -version 1.2.0
And then open your Developer command prompt for VS2015, and cd to the lib folder of downloaded package, for me it’s D:\Downloads\System.Reflection.Metadata.1.2.0\lib\netstandard1.1, and run the famous gacutil to install the assembly to GAC:
D:\Downloads\System.Reflection.Metadata.1.2.0\lib\netstandard1.1>gacutil -i System.Reflection.Metadata.dll Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0 Copyright (c) Microsoft Corporation. All rights reserved. Assembly successfully added to the cache
Open my solution again and it works! It might be not the best solution, but it works and I don’t have to reinstall VS2015, so I won’t complain.