0
votes

Since a couple of weeks I suddenly have issues with the SpecFlow extension in Visual Studio 2019 (professional edition). Out of the blue it stopped working. First I thought because of an update of VS, but other colleagues of mine are using the same (latest) version of VS and for them SpecFlow works.

The problems I'm experiencing are:

  • No settings menu for SpecFlow (Tools - Options - SpecFlow)
  • A NullReferenceException when opening a feature file (see end of post for entry of activity log)
  • When feature file is opened no syntax highlighting
  • No context menu

The test explorer is still discovering the tests and I can still run them, but not from the feature file (neither debugging the steps).

The extension is installed and enabled correctly (as far as I can tell). Already tried the following without success:

  • Uninstall and install the SpecFlow for Visual Studio 2019 extension
  • Uninstall SpecFlow and install Deveroom
  • Uninstall Visual Studio 2019 and install again

Any of you have any idea on what might be causing this?

Activity log entry

<entry>
  <record>806</record>
  <time>2021/02/09 09:25:56.786</time>
  <type>Error</type>
  <source>Editor or Editor Extension</source>
  <description>System.NullReferenceException: Object reference not set to an instance of an object.&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.ProjectScopeFactory.&lt;.ctor&gt;b__9_0() in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\ProjectScopeFactory.cs:line 52&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.Implementation.Utils.SynchInitializedInstance`1.EnsureInitialized()&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.ProjectScopeFactory.&lt;.ctor&gt;b__9_2(Project project) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\ProjectScopeFactory.cs:line 64&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.Implementation.Utils.SynchronizedResultCache`3.GetOrCreate(TSource source)&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.ProjectScopeFactory.GetProjectScope(Project project) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\ProjectScopeFactory.cs:line 76&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinLanguageServiceFactory.CreateLanguageService(ITextBuffer textBuffer) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinLanguageServiceFactory.cs:line 51&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinLanguageServiceFactory.&lt;&gt;c__DisplayClass7_0.&lt;GetLanguageService&gt;b__0() in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinLanguageServiceFactory.cs:line 43&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinBufferServiceManager.&lt;&gt;c__DisplayClass3_0`1.&lt;GetOrCreate&gt;b__0() in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinBufferServiceManager.cs:line 32&#x000D;&#x000A;
    at Microsoft.VisualStudio.Utilities.PropertyCollection.GetOrCreateSingletonProperty[T](Object key, Func`1 creator)&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinBufferServiceManager.GetOrCreate[TService](ITextBuffer textBuffer, Func`1 creator) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinBufferServiceManager.cs:line 29&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinLanguageServiceFactory.GetLanguageService(ITextBuffer textBuffer) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinLanguageServiceFactory.cs:line 43&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.GherkinFileEditor.GherkinFileClassifierProvider.&lt;&gt;c__DisplayClass3_0.&lt;GetClassifier&gt;b__0() in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\GherkinFileEditor\GherkinFileClassifierProvider.cs:line 31&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinBufferServiceManager.&lt;&gt;c__DisplayClass3_0`1.&lt;GetOrCreate&gt;b__0() in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinBufferServiceManager.cs:line 32&#x000D;&#x000A;
    at Microsoft.VisualStudio.Utilities.PropertyCollection.GetOrCreateSingletonProperty[T](Object key, Func`1 creator)&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.LanguageService.GherkinBufferServiceManager.GetOrCreate[TService](ITextBuffer textBuffer, Func`1 creator) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\LanguageService\GherkinBufferServiceManager.cs:line 29&#x000D;&#x000A;
    at TechTalk.SpecFlow.VsIntegration.GherkinFileEditor.GherkinFileClassifierProvider.GetClassifier(ITextBuffer buffer) in D:\a\1\s\TechTalk.SpecFlow.VSIXShared\GherkinFileEditor\GherkinFileClassifierProvider.cs:line 30&#x000D;&#x000A;
    at Microsoft.VisualStudio.Text.Classification.Implementation.ClassifierTaggerProvider.&lt;&gt;c__DisplayClass12_0`1.&lt;CreateTagger&gt;b__0(IClassifierProvider provider)&#x000D;&#x000A;
    at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InvokeEligibleFactories[TExtensionInstance,TExtensionFactory,TMetadataView](IEnumerable`1 lazyFactories, Func`2 getter, IContentType dataContentType, IContentTypeRegistryService contentTypeRegistryService, Object errorSource)&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;
    at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
  </description>
</entry>

Edited: After running a repair of VS I could see the menu option for the 'Clear MEF Component Cache' extension. Unfortunately using this got me no further with the SpecFlow extension (still the same issues).

2
I half wonder if deleting stuff in C:/Users/%USERNAME%/AppData/*/Microsoft/Visual Studio/{Version}/ComponentModelCache/ would do the trick as well.Greg Burghardt
Neither deleting the stuff in this folder nor installing the MEF cache cleaner worked.Eddie Terlouw

2 Answers

0
votes

This looks like the MEF cache of Visual Studio has a problem.
An easy way to clean it is the Clear MEF Component Cache extension from Mads Kristensen. It can be found on the marketplace here: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ClearMEFComponentCache

Install it and after a restart of VS, execute the command in the menu:

enter image description here

After that, restart VS again and the SpecFlow VS Extension should work again.

0
votes

Due to different issues I received a complete new image on my laptop from the IT department. Due to this the issues with SpecFlow are also resolved. I still don't know exactly what has caused this, but my guess would go to a slightly corrupted registry or something similar.

Anyway no need to answer this anymore.