Community.VisualStudio.Toolkit icon indicating copy to clipboard operation
Community.VisualStudio.Toolkit copied to clipboard

Community.VisualStudio.Toolkit.16 incorrectly compiles interop types

Open reduckted opened this issue 3 years ago • 0 comments

Steps to reproduce

  1. Create a new project using the VSIX Project w/Command (Community) template.
  2. Uninstall the Community.VisualStudio.Toolkit.17 package.
  3. Install the Community.VisualStudio.Toolkit.16 package.
  4. In the MyCommand class, add this statement to the ExecuteAsync method:
IVsThreadedWaitDialogFactory factory = (IVsThreadedWaitDialogFactory)await VS.Services.GetThreadedWaitDialogAsync();
  1. Debug the project and run the command. The command will fail with the error:
Exception thrown: 'System.InvalidCastException' in VSIXProject5.dll

It's an invalid cast because the IVsThreadedWaitDialogFactory type has been defined in the extension's assembly, so it's a different type to the service that was fetched. image

Workaround

This can be overcome by installing the Microsoft.VisualStudio.SDK.EmbedInteropTypes package.


I don't understand how this is occurring.

Community.VisualStudio.Toolkit.16 depends on Microsoft.VisualStudio.SDK, which depends on Microsoft.VisualStudio.SDK.EmbedInteropTypes.

In addition, Community.VisualStudio.Toolkit.16 also depends on Microsoft.VisualStudio.Shell.Interop.12.1.DesignTime, which depends on Microsoft.VisualStudio.SDK.EmbedInteropTypes.

So, Microsoft.VisualStudio.SDK.EmbedInteropTypes should be a dependency of the extension, yet I have to install it explicitly to correct how the interop types are compiled. 😕

reduckted avatar Jul 04 '22 11:07 reduckted