Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'AWSToolkitPackage' package did not load correctly - CompositionFailedException: Expected 1 export(s) with contract name IToolkitContextProvider #441

Closed
icelava opened this issue Jul 3, 2024 · 32 comments
Labels
bug We can reproduce the issue and confirmed it is a bug.

Comments

@icelava
Copy link

icelava commented Jul 3, 2024

Describe the bug
Today AWS Toolkit extension cannot load properly on launching Visual Studio 2022. AWS Explorer is an empty pane. It is not even listed in Extension Manager anymore and cannot be uninstalled or overwritten by AWS Toolkit with Amazon Q.


Microsoft Visual Studio

The 'AWSToolkitPackage' 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_45cd6749\ActivityLog.xml'.

Restarting Visual Studio could help resolve this issue.

Continue to show this error message?

Yes No

To Reproduce
Launch Visual Studio. Alone or with solution. Above error will pop up.

Expected behavior
AWS Explorer load up properly with all service nodes.

Screenshots

Toolkit Logs
ActivityLog.xml

  <entry>
    <record>1901</record>
    <time>2024/07/03 09:25:29.750</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [AWSToolkitPackage]Source: &apos;Microsoft.VisualStudio.Composition&apos; Description: Expected 1 export(s) with contract name &quot;Amazon.AWSToolkit.Context.IToolkitContextProvider&quot; but found 0 after applying applicable constraints.&#x000D;&#x000A;Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name &quot;Amazon.AWSToolkit.Context.IToolkitContextProvider&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.GetExportedValue[T]()&#x000D;&#x000A;
   at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService[T]()&#x000D;&#x000A;
   at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.&lt;GetMefComponentAsync&gt;d__72`1.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;
   at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.&lt;InitializeToolkitContextProviderAsync&gt;d__71.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;
   at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.&lt;InitializeAsync&gt;d__69.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Shell.AsyncPackage.&lt;&gt;c__DisplayClass21_0.&lt;&lt;Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize&gt;b__1&gt;d.MoveNext()&#x000D;&#x000A;--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#x000D;&#x000A;
   at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)</description>
    <guid>{0B82CB16-0E52-4363-9BC0-61E758689176}</guid>
    <hr>0x80131500</hr>
    <errorinfo></errorinfo>
  </entry>

Development System (please complete the following information):

  • Windows Version: Windows 11 23H2 22631.3737
  • Visual Studio Version: 17.10.3
  • AWS Toolkit for Visual Studio Version: Unknown - not listed in Extension Manager

Additional context
AWS Toolkit with Amazon Q cannot be installed over.


VSIX Installer

This extension is already installed to all applicable products.

OK

@icelava icelava added the bug We can reproduce the issue and confirmed it is a bug. label Jul 3, 2024
@bbdaniell
Copy link

I also have this issue. I believe I was using the most recent toolkit version prior to it breaking today, but I'm not completely sure. I've definitely updated it within the last few months.

Windows 11 Pro 23H2 22631.3810
Visual Studio 17.9.5

Initially the AWS Explorer tab was simply empty, but it now doesn't appear at all. The old version of the extension isn't visible anywhere I'm able to find in the Visual Studio UI, and the "AWS Toolkit with Amazon Q" appears as an installable extension (but doesn't install successfully.) Restarting Visual Studio does not solve the issue, nor does restarting my computer.

The current extension version (1.54.0.0, "AWS Toolkit with Amazon Q") does seem to exist in %ProgramFiles%\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions

@Reynolds80
Copy link

I am also having this issue, If I try and use "AWS Toolkit with Amazon Q" version It doesn't allow me to install. with the "This extension is already installed to all applicable products." Also getting the same "SetSite failed for package [AWSToolkitPackage]"

Please look at this!!!

Im on windows 10 Pro

@lumixtorix
Copy link

I also have this issue.

Windows 11 Pro 23H2
VS 2022

@tony-snoop
Copy link

Myself and a colleague have the same issue too!

@dan-snoop
Copy link

dan-snoop commented Jul 3, 2024

Exactly same issue for developers at my org as of today (oh, hi Tony!)

Cannot see the old extension listed in extension manager anymore, though the AWS Explorer still appears (if blank).

SetSite error appear in the ActivityLog.xml.

Cannot install the new version (with added Q!) as vsix installer says the extension is already installed.

@awschristou
Copy link
Contributor

Hi, and thank you for sharing details (particularly the ActivityLog.xml contents) relating to installing version 1.54.0.0. We are actively looking into this at the moment.

@awschristou
Copy link
Contributor

So the extension gets installed into %ProgramFiles%\Microsoft Visual Studio\2022\XXX\Common7\IDE\Extensions , where XXX is your Visual Studio edition (like Community, Professional, or Enterprise). Do not delete folders from within here, this can put Visual Studio into a state where it is unable to load extensions.

Each version of the extension gets installed into a new folder within this location.

  • 1.53.0.0 is installed to nymh0jqm.iwp
  • 1.54.0.0 is installed to p42bfph5.ab4
  • if you didn't have 1.53.0.0 previously installed, you'll have to search the folders for a file like AWSToolkitPackage.v17.dll in order to see which folder contains the Toolkit extension

I'd be interested to know if any of your systems currently has more than one of these folders existing at the same time.

@iakcaoglu
Copy link

Same issue here.
Windows 11 Pro 23H2
VS 2022 Version 17.10.3

Unable to uninstall even with CLI comments.
Reinstallation is not possible as it detects as installed!

Note: I have that file under only one location...
C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\p42bfph5.ab4

@awschristou
Copy link
Contributor

The Toolkit writes a log per session of Visual Studio to %localappdata%\AWSToolkit\logs\visualstudio\17.0 - any logs that can be shared from a session where the extension cannot be loaded would be appreciated.

@iakcaoglu
Copy link

log_2024-07-03_10-31-56_27244.txt
This is my latest log.

@olga-zmi
Copy link

olga-zmi commented Jul 3, 2024

Here is the error from ActivityLog.xml (referenced in pop-up error):

SetSite failed for package [AWSToolkitPackage]Source: 'Microsoft.VisualStudio.Composition' Description: Expected 1 export(s) with contract name "Amazon.AWSToolkit.Context.IToolkitContextProvider" but found 0 after applying applicable constraints.

Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name "Amazon.AWSToolkit.Context.IToolkitContextProvider" but found 0 after applying applicable constraints.
at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(ImportDefinition importDefinition)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[T,TMetadataView](String contractName, ImportCardinality cardinality)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T,TMetadataView](String contractName)
at Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValueT
at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetServiceT
at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d__72`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d__69.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass21_0.<b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)
at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)

@bbdaniell
Copy link

bbdaniell commented Jul 3, 2024

First log file that I noticed the issue: toolkit-crash-log.txt

Same solution, previous launch, which seemed to work fine: toolkit-ok-log.txt

And to confirm I only have the p42bfph5.ab4 folder present

@divyadyadey
Copy link

divyadyadey commented Jul 3, 2024

  1. Facing the exact same issue as mentioned above by everyone.

  2. Earlier atleast I was able to see this pop up window when I tried opening the project.
    image
    but presently nothing happens when I try opening the AWS explorer. I don't see any pop-up anymore

  3. Can't find AWS Toolkit for Visual Studio 2022 extension under Manage Extensions.

  4. Cannot install the new version (AWS Toolkit with Amazon Q) as VSIX installer says the extension is already installed.

  5. As mentioned above by @awschristou , I can only find p42bfph5.ab4 file within this location %ProgramFiles%\Microsoft Visual Studio\2022\XXX\Common7\IDE\Extensions

  6. Here is the error from ActivityLog.xml (referenced in pop-up error):
    SetSite failed for package [AWSToolkitPackage]Source: 'Microsoft.VisualStudio.Composition' Description: Expected 1 export(s) with contract name "Amazon.AWSToolkit.Context.IToolkitContextProvider" but found 0 after applying applicable constraints.
    Microsoft.VisualStudio.Composition.CompositionFailedException: Expected 1 export(s) with contract name "Amazon.AWSToolkit.Context.IToolkitContextProvider" but found 0 after applying applicable constraints.
    at Microsoft.VisualStudio.Composition.ExportProvider.GetExports(ImportDefinition importDefinition)
    at Microsoft.VisualStudio.Composition.ExportProvider.GetExports[T,TMetadataView](String contractName, ImportCardinality cardinality)
    at Microsoft.VisualStudio.Composition.ExportProvider.GetExport[T,TMetadataView](String contractName)
    at Microsoft.VisualStudio.Composition.ExportProvider.GetExportedValueT
    at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetServiceT
    at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d__72`1.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d__71.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d__69.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass21_0.<b__1>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e)
    at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck)

  7. Here is the latest log file from this location - %localappdata%\AWSToolkit\logs\visualstudio\17.0

log_2024-07-04_00-03-11_27940.txt

@olga-zmi
Copy link

olga-zmi commented Jul 3, 2024

You can uninstall this extension using VS installer. After that it could be installed again with extension manager.
It worked one time for me after that (the package was loaded), but with next launch of VS the same error returned

@awschristou
Copy link
Contributor

awschristou commented Jul 3, 2024

We have published a new version (1.54.0.1) to the extension marketplace.

With this release,

  • we have added some safeguards that should prevent the extension's startup from failing
  • we have added more logging to help diagnose if a similar problem persists

Please share whether or not you have been able to start using the updated extension. If you had issues installing and starting version 1.54.0.0 of the extension, and also continue to see problems with version 1.54.0.1, please try the following:

  • from a Visual Studio Developer Command prompt, run VSIXInstaller.exe /u:0B82CB16-0E52-4363-9BC0-61E758689176 to uninstall the extension.
  • restart your system
  • ensure that Visual Studio starts up clean (without any extension start-up issues or messages)
  • confirm that Visual Studio does not report the AWS Toolkit as installed in the Extension Manager
  • try installing the AWS Toolkit

(Update with additional troubleshooting steps)

  • if you continue to see a message in the output pane along the lines of "Some Toolkit components could not be initialized. Some functionality may not work during this IDE session.", or if the AWS Toolkit extension is not listed as installed in the Visual Studio Extension Manager, try repairing your Visual Studio installation. From the Start Menu, launch the Visual Studio Installer, and then click Repair.

@bbdaniell
Copy link

The 1.54.0.1 version installed with no issues for me from within Visual Studio and seems to be working properly again.

@icelava
Copy link
Author

icelava commented Jul 4, 2024

So the extension gets installed into %ProgramFiles%\Microsoft Visual Studio\2022\XXX\Common7\IDE\Extensions , where XXX is your Visual Studio edition (like Community, Professional, or Enterprise). Do not delete folders from within here, this can put Visual Studio into a state where it is unable to load extensions.

Each version of the extension gets installed into a new folder within this location.

  • 1.53.0.0 is installed to nymh0jqm.iwp
  • 1.54.0.0 is installed to p42bfph5.ab4
  • if you didn't have 1.53.0.0 previously installed, you'll have to search the folders for a file like AWSToolkitPackage.v17.dll in order to see which folder contains the Toolkit extension

I'd be interested to know if any of your systems currently has more than one of these folders existing at the same time.

Mine only has p42bfph5.ab4 (which appears to be Amazon Q). Visual Studio now launches without the pop-up error, but AWS Explorer does not appear when I choose it from View.

Extension Manager still doesn't show its presence.

@icelava
Copy link
Author

icelava commented Jul 4, 2024

1.54.0.1 has fixed this. AWS Explorer now loads properly. Thanks.

@icelava icelava closed this as completed Jul 4, 2024
@Reynolds80
Copy link

Im still having some issues.

I uninstalled as was suggested and reinstalled version (1.54.0.1)

When I load the following is displayed,

AWS Error1

If I attempt to deploy to AWS it fails after a while with the following error

AWS Error2

Log is here :
log_2024-07-04_09-04-03_25752.txt

@tony-snoop
Copy link

Hi @awschristou,

I followed your instructions and:

  • Launched a Visual Studio Developer Command Prompt from within Visual Studio ->Tools -> Command Line -> Developer command Prompt
  • uninstalled the extension using the VSIXInstaller.exe /u:0B82CB16-0E52-4363-9BC0-61E758689176 command from the Visual Studio Developer Command Prompt
  • closed down Visual Studio
  • waited for the extension to uninstall
  • restarted my machine
  • relaunched Visual Studio and reinstalled the AWS Toolkit from within the Extensions -> Managed Extensions window
  • closed down Visual Studio
  • Saw the extension window launch and install itself
  • relaunched Visual Studio again.

I can confirm that the AWS Explorer is now back (under the View menu) and that AWS Toolkit appears as a menu item under Extensions.

I couldn't see the AWS Toolkit extension in the installed tab within the Extensions -> Managed Extensions window though.
By the looks of it, everything appears to be working correctly again.

Thank you for getting a fix out so quickly.

@Reynolds80
Copy link

@tony-snoop hi are you able to deploy? ie when you right click a project and select "Publish to AWS" do you get all your options appear?

@tony-snoop
Copy link

tony-snoop commented Jul 4, 2024

@tony-snoop hi are you able to deploy? ie when you right click a project and select "Publish to AWS" do you get all your options appear?

Hi @Reynolds80 - We use an alternate method of publishing content to AWS using GIT and build triggers. So unfortunately I'm not sure if this works after uninstalling and re-installing the new AWS Toolkit update.

EDIT: I tried the right click -> publish to AWS menu item... and it did appear to launch a tab with 4 publish ASP.NET target options. I don't recognise this dialogue - but it appears to be loading and working fine (I didn't go any further).

@Reynolds80
Copy link

@tony-snoop Thanks for checking! it fails for me before that point. This may point to maybe a role missing from my permissions, or something like that. More digging!!

@awschristou
Copy link
Contributor

I've updated #441 (comment) with a suggestion to Repair your Visual Studio installation if you are seeing problems reported in this issue.

@Reynolds80
Copy link

Reynolds80 commented Jul 8, 2024

@awschristou Hi I just did a Repair, and the Publish to AWS still fails.

Error : "Publish to AWS failed to load publish details using the current credentials:
Unable to start a deployment session:"

AWS Explorer connects, and I'm able to see my databases/instances etc

If I validate the connection I receive a Connection is Valid.

Ill try the Publish to Elastic beanstalk (Legacy) next to see if that works.

Edit: I was able to deploy using the Elastic beanstalk (Legacy) method! Very strange.

@awschristou
Copy link
Contributor

Hi @Reynolds80 , if you are referring to the issue where you're seeing "Unable to start a deployment session" "A task was canceled" messages in Publish to AWS, can you please file that as a separate issue?

@awschristou awschristou changed the title The 'AWSToolkitPackage' package did not load correctly The 'AWSToolkitPackage' package did not load correctly - CompositionFailedException: Expected 1 export(s) with contract name IToolkitContextProvider Jul 8, 2024
@Kirkaiya
Copy link

The suggested fix - uninstalling the extension from a Visual Studio command prompt, rebooting, then re-installing from the marketplace, did appear to work. Until I then closed Visual Studio, and from a Unity project, double-clicked a script, which launches Visual Studio (and opens the project), at which point the toolkit was back in the broken state again, where it does not show as installed, and Q does not work (no "Q" icon at bottom), however in the Extensions menu, it still shows "AWS Toolkit".

I tried exiting Visual Studio, and restarting with a non-Unity project, and it was still broken. I then uninstalled the extension from VS developer command prompt again, and re-installed from the .visx file (without rebooting) and it appears to be fixed again. I'm reluctant to launch it again from Unity for fear of breaking it again.

@paulguz-datapa
Copy link

It is broken again for me, completely. Uninstalling the extension from the command prompt and reinstalling no longer fixes it. Not sure whether it's VS 17.10.4 or AWS Toolkit 1.55.00 that's broken it, I haven't tried reinstalling VS, but that seems a rather heavy handed fix.

@awschristou
Copy link
Contributor

Hi @paulguz-datapa , reinstalling VS would be heavy handed, and we don't know that it would definitely solve the problem, which we're still investigating.

Something you can try is to have Visual Studio rebuild its cache of MEF components (the AWS Toolkit is partially composed of MEF components, and this is where we're seeing failures). If you install the Clear MEF Component Cache extension and run it (as shown on the marketplace page) and then restart Visual Studio, it would be useful to know if there is any change in the Toolkit's ability to initialize properly.

@paulguz-datapa
Copy link

Thanks @awschristou, but clearing the component cache has had no effect.

@awschristou
Copy link
Contributor

Hi @paulguz-datapa , thanks for letting us know that you still have problems. We are now going to consolidate similar issues on an issue representing the core problem.

Can you please have a look at #452, and if your system is still in a bad state, please follow through the "help us out" section to help us collect more data about the problem.

If you are getting the "Some Toolkit components could not be initialized. Some functionality may not work during this IDE session." message, please comment on that issue going forward. Otherwise, please file a new issue, but try going through the guidance in 452.

@paulguz-datapa
Copy link

@awschristou OK, I've submitted the requested information to Microsoft. But when I run Visual Studio from the command prompt as requested, I don't get the AWS Toolkit error, so I'm not sure how much use that will be.

After going through the full process as described in the MS ticket, Amazon Q was briefly working again. But after signing in to give Amazon Q permission, the next time I started VS, Amazon Q failed again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug We can reproduce the issue and confirmed it is a bug.
Projects
None yet
Development

No branches or pull requests