Can't debug VSIX project: "Expected export ITextEditorFactoryService but found 0"

7

I am working in a couple of VSIX projects and suddenly, for some reason, I can't properly debug them. When I run the project, the experimental VS instance opens without issues, but as soon as I load a solution the problems begin.

To start with, if the solution I'm loading is under source control I get the following error message:

The 'GitCollaborationPackage' package did not load correctly. The problem may have been caused by a configuration change or by the installation of another extension.

There's also a link to a log file, which shows an apparently not very useful error message:

LegacySitePackage failed for package [GitCollaborationPackage] Source: "" Description: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

After that the solution loads, but as soon as I try to open a file I get this error:

Expected 1 export(s) with contract name "Microsoft.VisualStudio.Text.Editor.ITextEditorFactoryService" but found 0 after applying applicable constraints.

I didn't perform any significant change in my projects, but just in case I created a fresh new VSIX project and ran it right away, with identical results.

As suggested in MSDN I tried to delete Visual Studio's component cache and reset Visual Studio's settings, to no avail.

So what's going on here? What can I do to fix this?

UPDATE: A couple of new findings:

  • When running Visual Studio with devenv /safemode the problem persists.
  • This is happening in VS Professional edition. I have Community edition installed as well, and in that one I can debug without issues. Damn, that one got somehow corrupted too! :-(

UPDATE 2: Repairing Visual Studio didn't help.

visual-studio
visual-studio-2017
vsix
asked on Stack Overflow Sep 15, 2017 by Konamiman • edited Sep 18, 2017 by Konamiman

1 Answer

0

This is not an answer, but it's been two years and the problem remains serious, so I thought it might be worthwhile to add some detail for the sake of future investigation.

On my machine the experimental instance was working earlier today, but now it fails. The initial error most often reads

The 'RoslynPackage' package did not load correctly. The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users...\AppData\Roaming\Microsoft\VisualStudio\15.0_b0b65856Exp\ActivityLog.xml'.

But the failing package occasionally varies, and in any case the second error (involving ITextEditorFactoryService) soon follows.

Deleting the two VisualStudio\15.0_b0b65856Exp folders in AppData doesn't help, so I tried uninstalling and reinstalling VS2017. That didn't help either.

I tried debugging a "known good" Visual Studio extension. Same error. I tried loading a simple text file. Same error.

So I moved on to Visual Studio 2019 Community (which was already installed before the failures started). VS 2019 fails too, but its behavior is slightly different: the first error message does not appear, and the second error is slightly modified (notice the "2"):

Expected 1 export(s) with contract name "Microsoft.VisualStudio.Text.Editor.ITextEditorFactoryService2" but found 0 after applying applicable constraints.

I noticed that when I reinstalled VS2017, it still picked up on settings left over from the previous installation. And when the experimental instance starts, it asks me which theme I want. I tell it to use the Blue Theme, and for a few seconds it does, but then it loads Dark Theme which is the same theme used by the main instance. This leads to a hypothesis that the failure is caused by a "zombie" configuration setting that the experimental instance is choosing to load, a setting we just don't know how to get rid of. However, I tried dragging a .cs file onto the experimental instance immediately (before the dark theme loads) and the error still occurs. Also, I tried Tools -> Import and Export Settings -> Reset all Settings (inside the experimental instance), which didn't help.

In my case the command-line arguments /rootsuffix Exp /safemode prevent the error from happening, but this is useless because it also blocks the VSIX I'm trying to debug from loading.

Here are the entries in ActivityLog.xml that mention the word "error":

  <entry>
    <record>523</record>
    <time>2020/03/11 00:20:56.182</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [ProviderPackage]</description>
    <guid>{5F2E5E42-4192-4D79-A0D8-1D881E808829}</guid>
  </entry>

  <entry>
    <record>527</record>
    <time>2020/03/11 00:20:56.494</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [Microsoft.VisualStudio.Shell.Connected.Packages.PathTrustVerifier.PathTrustVerifierPackage]</description>
    <guid>{2F6B5046-3BB0-4825-B344-3F4238921119}</guid>
  </entry>

  <entry>
    <record>531</record>
    <time>2020/03/11 00:20:56.511</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [CSharpPackage]</description>
    <guid>{13C3BBB4-F18F-4111-9F54-A0FB010D9194}</guid>
  </entry>

  <entry>
    <record>534</record>
    <time>2020/03/11 00:20:56.590</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [RoslynPackage]</description>
    <guid>{6CF2E545-6109-4730-8883-CF43D7AEC3E1}</guid>
  </entry>

  <entry>
    <record>537</record>
    <time>2020/03/11 00:20:56.811</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [ErrorListPackage]</description>
    <guid>{4A9B7E50-AA16-11D0-A8C5-00A0C921A4D2}</guid>
  </entry>

  <entry>
    <record>541</record>
    <time>2020/03/11 00:20:57.014</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [Text Management Package]</description>
    <guid>{F5E7E720-1401-11D1-883B-0000F87579D2}</guid>
  </entry>

  <entry>
    <record>545</record>
    <time>2020/03/11 00:20:57.026</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [Microsoft.VisualStudio.Editor.Implementation.EditorPackage]</description>
    <guid>{E269B994-EF71-4CE0-8BCD-581C217372E8}</guid>
  </entry>

  <entry>
    <record>548</record>
    <time>2020/03/11 00:20:57.457</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>LegacySitePackage failed for package [RoslynPackage]Source: &apos;Microsoft.VisualStudio.Composition&apos; Description: Expected 1 export(s) with contract name &quot;Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource.VisualStudioDiagnosticListTableCommandHandler&quot; but found 0 after applying applicable constraints.&#x000D;&#x000A;Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name &quot;Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource.VisualStudioDiagnosticListTableCommandHandler&quot; but found 0 after applying applicable constraints.&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(ImportDefinition importDefinition)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[T,TMetadataView](String contractName, ImportCardinality cardinality)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T,TMetadataView](String contractName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T](String contractName)&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T]()&#x000D;&#x000A;   at Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValue[T]()&#x000D;&#x000A;   at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService[T]()&#x000D;&#x000A;   at Microsoft.VisualStudio.LanguageServices.Setup.RoslynPackage.LoadComponentsInUIContext()&#x000D;&#x000A;   at Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService.AbstractPackage.LoadComponentsInUIContextOnceSolutionFullyLoaded()&#x000D;&#x000A;   at Microsoft.VisualStudio.LanguageServices.Setup.RoslynPackage.Initialize()&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)</description>
    <guid>{6CF2E545-6109-4730-8883-CF43D7AEC3E1}</guid>
    <hr>80131500</hr>
    <errorinfo></errorinfo>
  </entry>

  <entry>
    <record>549</record>
    <time>2020/03/11 00:20:57.469</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [RoslynPackage](null)</description>
    <guid>{6CF2E545-6109-4730-8883-CF43D7AEC3E1}</guid>
    <hr>80131500</hr>
    <errorinfo></errorinfo>
  </entry>

  <entry>
    <record>551</record>
    <time>2020/03/11 00:20:57.479</time>
    <type>Warning</type>
    <source>VisualStudio</source>
    <description>Unexpected system error mode before loading package [Visual Studio Component Enumerator Package]</description>
    <guid>{588205E0-66E0-11D3-8600-00C04F6123B3}</guid>
  </entry>

  <entry>
    <record>555</record>
    <time>2020/03/11 00:20:57.490</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>End package load [RoslynPackage]</description>
    <guid>{6CF2E545-6109-4730-8883-CF43D7AEC3E1}</guid>
    <hr>80131500</hr>
    <errorinfo></errorinfo>
  </entry>

Note: the above error is the final entry in ActivityLog.xml; The second error doesn't show up here.

answered on Stack Overflow Mar 11, 2020 by Qwertie • edited Mar 11, 2020 by Qwertie

User contributions licensed under CC BY-SA 3.0