pharring / EditorGuidelines

A Visual Studio extension that adds vertical column guides to the text editor
MIT License
115 stars 17 forks source link

"Package did not load correctly" #87

Closed JVimes closed 2 years ago

JVimes commented 2 years ago

Maybe this isn't supported yet, but when I try to set a guideline in Visual Studio 17.1.0 Preview 1.0, I get:

The 'EditorGuidelinesPackage' 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\username\AppData\Roaming\Microsoft\VisualStudio\17.0_e8dd53cc\ActivityLog.xml'.

Restarting Visual Studio could help resolve this issue.

image

ActivityLog.xml shows:

<entry>
  <record>652</record>
  <time>2021/11/10 02:36:02.197</time>
  <type>Information</type>
  <source>VisualStudio</source>
  <description>Begin package load [EditorGuidelinesPackage]</description>
  <guid>{A0B80B01-BE16-4C42-AB44-7F8D057FAA2F}</guid>
</entry>
<entry>
  <record>653</record>
  <time>2021/11/10 02:36:02.198</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>LegacySitePackage failed for package [EditorGuidelinesPackage]Source: &apos;EditorGuidelines&apos; Description: Could not load file or assembly &apos;Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos; or one of its dependencies. The system cannot find the file specified.&#x000D;&#x000A;System.IO.FileNotFoundException: Could not load file or assembly &apos;Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos; or one of its dependencies. The system cannot find the file specified.&#x000D;&#x000A;File name: &apos;Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos;&#x000D;&#x000A;   at EditorGuidelines.EditorGuidelinesPackage.Initialize()&#x000D;&#x000A;   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)&#x000D;&#x000A;&#x000D;&#x000A;WRN: Assembly binding logging is turned OFF.&#x000D;&#x000A;To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.&#x000D;&#x000A;Note: There is some performance penalty associated with assembly bind failure logging.&#x000D;&#x000A;To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].&#x000D;&#x000A;</description>
  <guid>{A0B80B01-BE16-4C42-AB44-7F8D057FAA2F}</guid>
  <hr>80070002</hr>
  <errorinfo></errorinfo>
</entry>
<entry>
  <record>654</record>
  <time>2021/11/10 02:36:02.202</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>SetSite failed for package [EditorGuidelinesPackage](null)</description>
  <guid>{A0B80B01-BE16-4C42-AB44-7F8D057FAA2F}</guid>
  <hr>80070002</hr>
  <errorinfo></errorinfo>
</entry>
<entry>
  <record>655</record>
  <time>2021/11/10 02:36:02.206</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>End package load [EditorGuidelinesPackage]</description>
  <guid>{A0B80B01-BE16-4C42-AB44-7F8D057FAA2F}</guid>
  <hr>80070002</hr>
  <errorinfo></errorinfo>
</entry>
bddckr commented 2 years ago

Same FileNotFoundException for Microsoft.ApplicationInsights happening for me on 17.1.0 Preview 1.0 as well.

(Thanks for this great extension btw!)

pharring commented 2 years ago

Thanks for the bug report and sorry for the inconvenience. I haven't been able to reproduce it myself and I'm also on 17.1.0 Preview 1.0 (Community edition)

I suspect it might be related to other installed extensions that are pre-empting the loading of Microsoft.ApplicationInsights. @bddckr would you mind listing what other extensions you have installed?

bddckr commented 2 years ago

@pharring Sure, here you go!

{
  "id": "a3f047ea-dcc3-473f-bb4f-8a9a27f5fa4c",
  "name": "My Visual Studio extensions",
  "description": "A collection of my Visual Studio extensions",
  "version": "1.0",
  "extensions": [
    {
      "name": "Add New File (64-bit)",
      "vsixId": "d48e8f25-661b-4970-8b66-03f051ba5fc3"
    },
    {
      "name": "CodeMaid VS2022",
      "vsixId": "9079e73d-3fbb-4e07-8dab-f44fa5d8e8b5"
    },
    {
      "name": "Editor Guidelines (Preview)",
      "vsixId": "EditorGuidelines.f7dfa085-35e4-4844-8842-48298d5eaee0"
    },
    {
      "name": "Extension Manager 2022",
      "vsixId": "4a196712-2c3f-4730-ad1d-e7cda4185eb3"
    },
    {
      "name": "F# Formatting",
      "vsixId": "FantomasVs.4acfe0e3-4521-45ed-9c32-9265806f4108"
    },
    {
      "name": "File Icons",
      "vsixId": "3a7b4930-a5fb-46ec-a9b8-9610c8f953b8"
    },
    {
      "name": "Fix Mixed Tabs 2022",
      "vsixId": "FixMixedTabs2022.9f1d3050-b986-4b10-ae36-97c6efc5e968"
    },
    {
      "name": "Markdown Editor (64-bit)",
      "vsixId": "9ca64947-e9ca-4543-bfb8-6cce9be19fd7"
    },
    {
      "name": "Match Margin 2022",
      "vsixId": "MatchMargin2022.d85a25b5-f7b3-46a9-997e-a2d669dc2c93"
    },
    {
      "name": "Open in Visual Studio Code",
      "vsixId": "e99dde0e-e023-410d-bc5d-3f76db71e3f0"
    },
    {
      "name": "Rewrap",
      "vsixId": "Rewrap.stkb.4d01f0ab-ed41-47cc-a43f-777f84fcf51e"
    },
    {
      "name": "Shrink Empty Lines 2022",
      "vsixId": "SyntacticLineCompression2022.4452fb8f-b348-49eb-9499-76669d3f9c75"
    },
    {
      "name": "SideScroller",
      "vsixId": "SideScroller.Vsix.d0f12930-4bcc-455c-b681-f765aaab3d6f"
    },
    {
      "name": "Subword Navigation",
      "vsixId": "ad7396e5-bd21-4114-90e6-36d157cbcc84"
    },
    {
      "name": "Time Stamp Margin 2022",
      "vsixId": "TimeStampMargin2022.255e8b14-4a53-4eb7-89a7-7ab741c1f612"
    },
    {
      "name": "Visual Studio Spell Checker (VS2022 and Later)",
      "vsixId": "E1019027-EE37-4B1A-AD4C-25CAA92CA2D5"
    },
    {
      "name": "VSColorOutput64",
      "vsixId": "65dd734b-180a-4c67-b245-56de889637e1"
    }
  ]
}

Thanks for looking into this.

pharring commented 2 years ago

@bddckr @JVimes thanks again for the report. I suspect the problem is with the "upgrade" from 17.0 preview to 17.1 preview. If anyone sees this on 17.0 Current (that's what they're calling the stable channel now), let me know.

I saw a slightly different problem myself in 17.1 Preview: The package loaded without error (right-click menu works), but the editor adornment did not load due to a MEF composition failure.

Please could you also try one troubleshooting step for me:

After that, launch VS and try again. You'll need to sign into VS again. Re-install Editor Guidelines and see if it works. You may have to re-install all your other extensions manually (I'm not sure if "Roaming Settings" will automatically install them eventually).

Let me know whether it works or not.

JVimes commented 2 years ago

Thank you @pharring. I still get the error message after devenv /resetuserdata. I believe problem started for me, as you suspected, after updating from 17.0 Preview to 17.1 Preview.

Curious if it relates to that error message (above) in ActivityLog.xml:

LegacySitePackage failed for package [EditorGuidelinesPackage]
Source: 'EditorGuidelines' Description: Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at EditorGuidelines.EditorGuidelinesPackage.Initialize()
   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsPackage.SetSite(IServiceProvider sp)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
pharring commented 2 years ago

Thanks. Yes, that FileNotFoundException is what I'm trying to understand. The file in question -- Microsoft.ApplicationInsights.dll -- is bundled with the Editor Guidelines package (VSIX). It's also included in Visual Studio itself.

One difference that seems relevant between 17.0 and 17.1 appears in devenv.exe.config:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
  <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0"/>
  <codeBase version="2.1.0.0" href="Extensions\Microsoft\AppInsights\Core\Microsoft.ApplicationInsights.dll" />
</dependentAssembly>

That's from 17.1. It refers to version of Microsoft.ApplicationInsights.dll in the "Extensions\Microsoft\AppInsights\Core" folder, but that folder isn't present on my machine. I installed the Community edition with minimal workloads. I assume it's a bug in authoring for 17.1 -- that codeBase entry shouldn't be there unless the relevant workload is also installed.

One workaround would be to hand-edit the devenv.exe.config file (need to run as administrator to edit it) and remove that whole dependentAssembly entry. Another would be to find which workload brings in that "Extensions\Microsoft\AppInsights\Core" folder. I'm looking into that.

pharring commented 2 years ago

Found it: "Developer Analytics tools" Launch the Visual Studio Installer, find the VS 2022 Preview channel and select "Modify" Then go to "Individual Components" and search for "Developer Analytics". Check the "Developer Analytics tools" check box and update your installation. image

That should fix it. @JVimes @bddckr FYI. Please try the steps above and let me know if the issue is fixed.

JVimes commented 2 years ago

That worked around the problem for me, thank you. Hopefully a fix isn't too hard.

pharring commented 2 years ago

The fix will have to come from the Visual Studio team in a 17.1 update. I've engaged VSIX support on an internal channel and I'll also file a feedback ticket.

pharring commented 2 years ago

Feedback ticket: https://developercommunity.visualstudio.com/t/devenvexeconfig-supplies-a-codeBase-fo/1579190

bddckr commented 2 years ago

Installing Developer Analytics tools to 17.1.0 Preview 1 worked to restore the extension's functionality for me as well, thank you!

pharring commented 2 years ago

Thanks for confirming.

alexanderbock commented 2 years ago

Same issue is occurring on the released 17.1.0 with the same working-around still functional and necessary

john-preston commented 2 years ago

Yes, I can confirm this is still happening in the 17.1 released to the stable channel.

As I see in the feedback ticket this is only going to be fixed in 17.2. Thanks for the extension! And the workaround, it works :)

ssg commented 2 years ago

I'm adding the stack trace here, so anyone searching for it can find this ticket and the workaround. Thanks!

A MEF Component threw an exception at runtime: Microsoft.VisualStudio.Composition.CompositionFailedException: An exception was thrown while initializing part "EditorGuidelines.ColumnGuideAdornmentFactory". ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ApplicationInsights, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at EditorGuidelines.ColumnGuideAdornmentFactory.OnImportsSatisfied() --- End of inner exception stack trace --- at Microsoft.VisualStudio.Composition.RuntimeExportProviderFactory.RuntimeExportProvider.RuntimePartLifecycleTracker.InvokeOnImportsSatisfied() at Microsoft.VisualStudio.Composition.ExportProvider.PartLifecycleTracker.NotifyTransitiveImportsSatisfied() 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.b__0()

sudo-rm-rf-oops commented 2 years ago

Just wanted to say thank you @pharring for researching and posting a workaround. Made my day.

SiP-muav commented 2 years ago

Hi Paul, following your musings on options to deal with absent/mislinked component in 17.1, I have tried the edit devenv.exe.config route, and can confirm it as workable.

Two observations:

In general, I would like to thank you for ongoing support and excellent code. Kudos for convincing minders of the root cause to fix things - I'll await it on regular update channel. Cheers!

SiP-muav commented 2 years ago

Another thought: a small temporary note (until mainstream VS is fixed) on your feature page (https://marketplace.visualstudio.com/items?itemName=PaulHarrington.EditorGuidelinesPreview&ssr=false#overview) briefly cautioning hopeful users that there is a known issue with a workaround, would have actually pre-empted me from contacting you, as the solution is already covered in github. Just an idea. Cheers! - Sid

Ziflin commented 2 years ago

I can confirm that updating to VS 2022 v17.2.x fixes the above issue.

dimasahmad commented 2 years ago

I can confirm that updating to VS 2022 v17.2.x fixes the above issue.

I'm using version 17.2.3 and still got the same error

image

and reopening the devenv caused this error

System.InvalidOperationException
The service 'Microsoft.VisualStudio.Shell.Interop.IVsTaskList' must be installed for this feature to work.  Ensure that this service is available.

   at Microsoft.VisualStudio.Shell.TaskProvider.get_VsTaskList()
   at Microsoft.VisualStudio.Shell.TaskProvider.Refresh()
   at Microsoft.VisualStudio.Shell.TaskProvider.ResumeRefresh()
   at Microsoft.VisualStudio.Data.Tools.Package.UI.DataSchemaErrorTaskHelper.AddTasks(IList`1 tasks)
   at Microsoft.VisualStudio.Data.Tools.Package.UI.DataSchemaErrorTaskService.ProcessErrorsInQueue(Boolean ignoreQueueStabilization)
   at Microsoft.VisualStudio.Data.Tools.Package.IdleProcessingComponent.FDoIdle(UInt32 grfidlef)
pharring commented 2 years ago

I haven't seen that one before.

For sure, a missing IVsTaskList service would be a problem for many packages, but I don't think EditorGuidelines uses it. I suspect you have a general problem with your installation and EditorGuidelines happened to be fingered as the culprit.

The call-stack indicates that it's coming from the data tools package (not editor guidelines). Was there another error/exception in the activity log with EditorGuidelines in the callstack?