Skip to content

Latest nightly build of Visual FSharp Tools fails to load at first #3040

@rmunn

Description

@rmunn

This might be related to #2917, especially since the problem appears to have solved itself after restarting Visual Studio a couple of times. I'm submitting this bug report anyway since it might contain useful details for debugging whatever caused this intermittent issue, but feel free to close the report as soon as it's no longer useful.

I just updated the Visual FSharp Tools to version 15.4.1.17051201 (in Visual Studio 2017 Update 2 on Windows 10, BTW) and, when I started up Visual Studio, I got the error "The 'FSharpPackage' package did not load correctly." Screenshot:

image

Looking at the activity log, the relevant bits of the log seem to be the following:

  <entry>
    <record>332</record>
    <time>2017/05/12 09:01:27.523</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [FSharpProjectPackage]</description>
    <guid>{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}</guid>
  </entry>
  <entry>
    <record>335</record>
    <time>2017/05/12 09:01:27.618</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [FSharpPackage]</description>
    <guid>{871D2A70-12A2-4E42-9440-425DD92A4116}</guid>
  </entry>
  <entry>
    <record>348</record>
    <time>2017/05/12 09:01:28.292</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>LegacySitePackage failed for package [FSharpPackage]Source: &apos;Microsoft.VisualStudio.ExtensibilityHosting&apos; Description: The Visual Studio component cache is out of date (assembly: FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a). Please restart Visual Studio.&#x000D;&#x000A;</description>
    <guid>{871D2A70-12A2-4E42-9440-425DD92A4116}</guid>
    <hr>80131500</hr>
    <errorinfo></errorinfo>
  </entry>
  <entry>
    <record>349</record>
    <time>2017/05/12 09:01:28.294</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [FSharpPackage](null)</description>
    <guid>{871D2A70-12A2-4E42-9440-425DD92A4116}</guid>
    <hr>80131500</hr>
    <errorinfo></errorinfo>
  </entry>
  <entry>
    <record>350</record>
    <time>2017/05/12 09:01:28.391</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>End package load [FSharpPackage]</description>
    <guid>{871D2A70-12A2-4E42-9440-425DD92A4116}</guid>
    <hr>80131500</hr>
    <errorinfo></errorinfo>
  </entry>
  <entry>
    <record>355</record>
    <time>2017/05/12 09:11:41.959</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>End package load [FSharpProjectPackage]</description>
    <guid>{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}</guid>
  </entry>

I trimmed parts of the log that seemed irrelevant, but I can add the whole activity log if someone thinks there's something in there that would be useful in identifying the cause. The parts I snipped were several occurrences of "Entering function CVsPackageInfo::HrInstantiatePackage", and pairs of "Begin package load" / "End package load" messages for RoslynPackage, ErrorListPackage, Text Management Package, and Microsoft.VisualStudio.Editor.Implementation.EditorPackage.

Then when I loaded up an F# project (a basic console application I had just created in Visual Studio), the following was added to the activity log:

  <entry>
    <record>452</record>
    <time>2017/05/12 09:11:50.302</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>A MEF Component threw an exception at runtime: Microsoft.VisualStudio.ExtensibilityHosting.InvalidMEFCacheException: The Visual Studio component cache is out of date (assembly: FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a). Please restart Visual Studio.&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.&lt;&gt;c__DisplayClass17_0.&lt;LoadAssembly&gt;b__0(AssemblyName assemblyNameParam)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.Utilities.SafeGetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Object lockObj, Func`2 valueFactory)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.LoadAssembly(AssemblyName assemblyName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(ConstructorRef constructorRef)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimePart.get_ImportingConstructor()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0()</description>
  </entry>
  <entry>
    <record>453</record>
    <time>2017/05/12 09:11:50.302</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is out of date.</description>
  </entry>
  <entry>
    <record>454</record>
    <time>2017/05/12 09:11:50.308</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>Microsoft.VisualStudio.ExtensibilityHosting.InvalidMEFCacheException: The Visual Studio component cache is out of date (assembly: FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a). Please restart Visual Studio.&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.&lt;&gt;c__DisplayClass17_0.&lt;LoadAssembly&gt;b__0(AssemblyName assemblyNameParam)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.Utilities.SafeGetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Object lockObj, Func`2 valueFactory)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.LoadAssembly(AssemblyName assemblyName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(ConstructorRef constructorRef)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimePart.get_ImportingConstructor()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.DelegateServices.&lt;&gt;c__DisplayClass2_0`1.&lt;As&gt;b__0()&#x000D;&#x000A;   at System.Lazy`1.CreateValue()&#x000D;&#x000A;   at System.Lazy`1.LazyInitValue()&#x000D;&#x000A;   at System.Lazy`1.get_Value()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata](Object errorSource, Lazy`2 provider)</description>
  </entry>
  <entry>
    <record>455</record>
    <time>2017/05/12 09:11:50.309</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>A MEF Component threw an exception at runtime: Microsoft.VisualStudio.ExtensibilityHosting.InvalidMEFCacheException: The Visual Studio component cache is out of date (assembly: FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a). Please restart Visual Studio.&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.&lt;&gt;c__DisplayClass17_0.&lt;LoadAssembly&gt;b__0(AssemblyName assemblyNameParam)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.Utilities.SafeGetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Object lockObj, Func`2 valueFactory)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.LoadAssembly(AssemblyName assemblyName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.Reflection.TypeRef.get_ResolvedType()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_ImportingSiteType()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_ImportingSiteTypeWithoutCollection()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_IsLazy()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_LazyFactory()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.&lt;CreateValue&gt;b__10_0(RuntimeImport import)&#x000D;&#x000A;   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()&#x000D;&#x000A;   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)&#x000D;&#x000A;   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0()</description>
  </entry>
  <entry>
    <record>456</record>
    <time>2017/05/12 09:11:50.309</time>
    <type>Error</type>
    <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
    <description>FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is out of date.</description>
  </entry>
  <entry>
    <record>457</record>
    <time>2017/05/12 09:11:50.310</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>Microsoft.VisualStudio.ExtensibilityHosting.InvalidMEFCacheException: The Visual Studio component cache is out of date (assembly: FSharp.Editor, Version=15.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a). Please restart Visual Studio.&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.&lt;&gt;c__DisplayClass17_0.&lt;LoadAssembly&gt;b__0(AssemblyName assemblyNameParam)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.Utilities.SafeGetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Object lockObj, Func`2 valueFactory)&#x000D;&#x000A;   at Microsoft.VisualStudio.ExtensibilityHosting.FaultCatchingAssemblyLoader.LoadAssembly(AssemblyName assemblyName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.Reflection.TypeRef.get_ResolvedType()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_ImportingSiteType()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_ImportingSiteTypeWithoutCollection()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_IsLazy()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeComposition.RuntimeImport.get_LazyFactory()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.GetValueForImportSite(RuntimePartLifecycleTracker importingPartTracker, RuntimeImport import)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.&lt;CreateValue&gt;b__10_0(RuntimeImport import)&#x000D;&#x000A;   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()&#x000D;&#x000A;   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)&#x000D;&#x000A;   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.CreateValue()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.Create()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.MoveNext(PartLifecycleState nextState)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.GetValueReadyToExpose()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.&lt;&gt;c__DisplayClass15_0.&lt;GetExportedValueHelper&gt;b__0()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.DelegateServices.&lt;&gt;c__DisplayClass2_0`1.&lt;As&gt;b__0()&#x000D;&#x000A;   at System.Lazy`1.CreateValue()&#x000D;&#x000A;   at System.Lazy`1.LazyInitValue()&#x000D;&#x000A;   at System.Lazy`1.get_Value()&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata](Object errorSource, Lazy`2 provider)</description>
  </entry>

I thought I would try clearing the component model cache, but when I went to C:\Users\Robin\AppData\Local\Microsoft\VisualStudio\15.0_1847dea7\ComponentModelCache to clear it out, I discovered that the folder was completely empty. And then, the next time I restarted Visual Studio, the Visual FSharp Tools crash went away, and I was able to edit F# code normally.

I assume that some other part of Visual Studio, whether it was the F# Tools or something else, cleared the invalid ComponentModelCache before I got to it, and that's why the error went away after a restart of Visual Studio. (A second or third restart, incidentally: the first couple of times I started VS, the problem persisted, which is why I thought a bug report would be necessary).

Since the problem went away, I almost considered not submitting any report about it -- but I decided to submit this report anyway since those activity-log messages might turn out to be useful if this is some long-running issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-SetupAndDeliverySetup, packages, templates, SDK, delivery channels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions