aws / aws-toolkit-visual-studio

AWS Toolkit for Visual Studio - a plugin to interact with AWS
https://aws.amazon.com/visualstudio/
Apache License 2.0
110 stars 29 forks source link

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

Closed icelava closed 4 months ago

icelava commented 4 months ago

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):

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


VSIX Installer

This extension is already installed to all applicable products.

OK

bbdaniell commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

I also have this issue.

Windows 11 Pro 23H2 VS 2022

tony-snoop commented 4 months ago

Myself and a colleague have the same issue too!

dan-snoop commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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.

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

olga-zmi commented 4 months ago

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.GetExportedValue[T]() at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService[T]() at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d72`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.d71.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.d69.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.<>cDisplayClass21_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 commented 4 months ago

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 commented 4 months ago
  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.GetExportedValue[T]() at Microsoft.VisualStudio.ComponentModelHost.ComponentModel.GetService[T]() at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.d72`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.d71.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.d69.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.<>cDisplayClass21_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 commented 4 months ago

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 commented 4 months ago

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

With this release,

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:

(Update with additional troubleshooting steps)

bbdaniell commented 4 months ago

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

icelava commented 4 months ago

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 commented 4 months ago

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

Reynolds80 commented 4 months ago

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 commented 4 months ago

Hi @awschristou,

I followed your instructions and:

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 commented 4 months ago

@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 commented 4 months ago

@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 commented 4 months ago

@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 commented 4 months ago

I've updated https://github.com/aws/aws-toolkit-visual-studio/issues/441#issuecomment-2207475901 with a suggestion to Repair your Visual Studio installation if you are seeing problems reported in this issue.

Reynolds80 commented 4 months ago

@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 commented 4 months ago

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?

Kirkaiya commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

awschristou commented 3 months ago

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 https://github.com/aws/aws-toolkit-visual-studio/issues/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 commented 3 months ago

@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.