roslyn: quick actions and refactoring ArgumentNullReferenceException
This issue has been moved from a ticket on Developer Community.
When I call quick actions and refactoring for the first time, I get an ArgumentNullReferenceException and the namespace adding function no longer works. The error occurred on version 16.5.0 and 16.5.1 Last entries in ActivityLog
<entry>
<record>3067</record>
<time>2020/03/30 09:12:51.668</time>
<type>Error</type>
<source>Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost</source>
<description>An invalid MEF cache has been found due to a mismatching timestamp or MVID: Microsoft.VisualStudio.ExtensibilityHosting.InvalidMEFCacheException: The Visual Studio component cache is out of date (assembly: Microsoft.CodeQuality.CSharp.Analyzers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35). Please restart Visual Studio.;VS.Platform.ExtensibilityHosting.MefCacheInvalidation.LoadedAssembly.Name=Microsoft.CodeQuality.CSharp.Analyzers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35;VS.Platform.ExtensibilityHosting.MefCacheInvalidation.LoadedAssembly.CodeBase=file:///C:/Users/LIFEf/AppData/Local/Temp/VS/AnalyzerAssemblyLoader/af398bdbd73c42d5aeb059f77ebba698/6/Microsoft.CodeQuality.CSharp.Analyzers.dll;VS.Platform.ExtensibilityHosting.MefCacheInvalidation.ActualTimestamp=637206708100000000;VS.Platform.ExtensibilityHosting.MefCacheInvalidation.ExpectedTimestamp=637090033026102134;VS.Platform.ExtensibilityHosting.MefCacheInvalidation.ActualMVID=8f2d5d8d-d636-4c79-8689-080cc192c23c;VS.Platform.ExtensibilityHosting.MefCacheInvalidation.ExpectedMVID=35e2cd95-b028-45e3-81fa-8837a703b945
</description>
</entry>
<entry>
<record>3068</record>
<time>2020/03/30 09:12:51.676</time>
<type>Error</type>
<source>Microsoft.VisualStudio.ComponentModelHost.VsShellComponentModelHost</source>
<description>A MEF Component threw an exception at runtime: System.ArgumentNullException: Value cannot be null.
Parameter name: type
 at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type type)
 at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(MethodRef methodRef)
 at Microsoft.VisualStudio.Composition.Reflection.MethodRef.Resolve()
 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()</description>
</entry>
<entry>
<record>3069</record>
<time>2020/03/30 09:12:56.780</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.ArgumentNullException: Value cannot be null.
Parameter name: type
 at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type type)
 at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(MethodRef methodRef)
 at Microsoft.VisualStudio.Composition.Reflection.MethodRef.Resolve()
 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.CodeAnalysis.CodeFixes.CodeFixService.<>c__DisplayClass31_1.<GetFixerPerLanguageMap>b__0()
 at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
 at System.Lazy`1.get_Value()
 at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.<AppendFixesAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
 at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.<GetFixesAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at Roslyn.Utilities.TaskExtensions.WaitAndGetResult_CanCallOnBackground[T](Task`1 task, CancellationToken cancellationToken)
 at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionsSourceProvider.SuggestedActionsSource.GetCodeFixes(ITextBufferSupportsFeatureService supportsFeatureService, ISuggestedActionCategorySet requestedActionCategories, Workspace workspace, Document document, SnapshotSpan range, Func`2 addOperationScope, CancellationToken cancellationToken)
 at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionsSourceProvider.SuggestedActionsSource.GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, IUIThreadOperationContext operationContext, CancellationToken cancellationToken)
 at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionsSourceProvider.SuggestedActionsSource.GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, IUIThreadOperationContext operationContext)
 at Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulbSession.<>c__DisplayClass40_4.<TryGetSuggestedActionSets>b__1()
 at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint[T](Object errorSource, Func`1 call, T valueOnThrow)
--- End of stack trace from previous location where exception was thrown ---
 at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
</entry>
System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type type)
at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(MethodRef methodRef)
at Microsoft.VisualStudio.Composition.Reflection.MethodRef.Resolve()
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.CodeAnalysis.CodeFixes.CodeFixService.<>c__DisplayClass31_1.<GetFixerPerLanguageMap>b__0()
at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.<AppendFixesAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.CodeAnalysis.CodeFixes.CodeFixService.<GetFixesAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Roslyn.Utilities.TaskExtensions.WaitAndGetResult_CanCallOnBackground[T](Task`1 task, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionsSourceProvider.SuggestedActionsSource.GetCodeFixes(ITextBufferSupportsFeatureService supportsFeatureService, ISuggestedActionCategorySet requestedActionCategories, Workspace workspace, Document document, SnapshotSpan range, Func`2 addOperationScope, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionsSourceProvider.SuggestedActionsSource.GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, IUIThreadOperationContext operationContext, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionsSourceProvider.SuggestedActionsSource.GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, IUIThreadOperationContext operationContext)
at Microsoft.VisualStudio.Language.Intellisense.Implementation.LightBulbSession.<>c__DisplayClass40_4.<TryGetSuggestedActionSets>b__1()
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint[T](Object errorSource, Func`1 call, T valueOnThrow)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
Original Comments
Visual Studio Feedback System on 3/30/2020, 02:35 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
(no solutions)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 17 (5 by maintainers)
@JaCraig @LIFEfreedom @gh5692 Can you guys check if you have installed “Microsoft Code Analysis 2019” VSIX extension locally: https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MicrosoftCodeAnalysis2019? If so, please uninstall this VSIX and try again.
Thanks everyone! I am going to prioritize the work of making the Microsoft CodeAnalysis 2019 Extension/VSIX as deprecated and update the docs accordingly.
I have the same issue.
This happens as soon as I try and access the quick actions context menu. The MEF cache error is no longer present in my log (I ran devenv.exe /updateconfiguration to fix that error). I recently updated Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package from 2.9.8 to 3.0.0, and the errors started occurring sometime after the update. This is in Visual Studio 2019 16.5.4 for a project targeting .NET Framework 4.8.
Downgrading Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package from 3.0.0 to 2.9.9 seems to have fixed it for me.