Reputation: 3727
I'm running Visual Studio 2015 with some extensions.
I'm trying to debug the following error I'm getting:
The errors are logged in ActivityLog.xml
:
440 ERROR A MEF Component threw an exception at runtime: System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeMethodInfo' to type 'System.Reflection.ConstructorInfo'.
at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(ConstructorRef constructorRef)
at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimePart.get_ImportingConstructor()
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()
Source: Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost
Time: 2016/09/12 07:16:43.932
441 ERROR System.InvalidCastException: Unable to cast object of type 'System.Reflection.RuntimeMethodInfo' to type 'System.Reflection.ConstructorInfo'.
at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(ConstructorRef constructorRef)
at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimePart.get_ImportingConstructor()
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() --- End of stack trace from previous location where exception was thrown ---
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.VisualStudio.Text.Utilities.GuardedOperations.InvokeEligibleFactories[TExtensionInstance,TExtensionFactory,TMetadataView](IEnumerable`1 lazyFactories, Func`2 getter, IContentType dataContentType, IContentTypeRegistryService contentTypeRegistryService, Object errorSource)
Source: Editor or Editor Extension
Time: 2016/09/12 07:16:44.075
Errors are reported with Source
of Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost
and Editor or Editor Extension
.
The errors do not mention which extension caused the error and I can't find any hints where to look for the problem.
When running with debugger (devenv.exe" /RootSuffix Exp
) the debugger does not stop on the exceptions, and the error message box still appears.
After closing Visual Studio, restarting the machine, re-installing an extension etc., the problem is gone.
I'm not happy about this, as I was not able to root-cause the issue or get any good hint where to look / how to debug this.
Upvotes: 6
Views: 1199
Reputation: 6706
I solved the problem by deleting every relevant directory in <user>\AppData\Local\Microsoft\VisualStudio\
(The 'lower level' reset call didn't work because it couldn't find the directory blahblah\15.0Exp\
. )
Btw, I use VS2017RCUpdate3.
Upvotes: -1
Reputation: 10931
Visual Studio 2015 Update 3 (at least) provides a start menu item:
Visual Studio 2015 > Reset the Visual Studio 2015 Experimental Instance
It seems to be lower level and simpler than the accepted answer: it calls
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\
VisualStudioIntegration\Tools\Bin\CreateExpInstance.exe"
/Reset /VSInstance=14.0 /RootSuffix=Exp
which seems to just delete and recreate the relevant files.
Upvotes: 10
Reputation: 18976
That error means that a cache in Visual Studio of extension information and the extensions you had installed got out of sync. It's not (likely) the fault of any extension itself, but rather a bug in Visual Studio. Make sure you're on the latest version with all updates installed -- we've fixed a few bugs in recent months that might cause something to go wrong. If you want to force the cache to be rebuilt, you can run:
devenv /updateconfiguration
To force the cache to be rebuilt on the next run.
Upvotes: 5
Reputation: 6436
To make sure that whether it is related to the add-ins or extension tool, you can run your VS in safe mode:
devenv /SafeMode
If it works well in safe mode, we would think about them.
Based on the messages in your comments, I also didn't fine the error messages which share that which extension tool impacts the VS IDE.
Like this document here:
http://blog.masterdevs.com/debugging-a-visual-studio-crash/
You need to collect and view the detailed error messages like "which dll files or packages were not loaded or others", if you make sure that no other error messages, maybe you could clean the temp/AppData files, re-open your VS, check it again.
Upvotes: 2