Community.VisualStudio.Toolkit.16 incorrectly compiles interop types
Steps to reproduce
- Create a new project using the VSIX Project w/Command (Community) template.
- Uninstall the
Community.VisualStudio.Toolkit.17package. - Install the
Community.VisualStudio.Toolkit.16package. - In the
MyCommandclass, add this statement to theExecuteAsyncmethod:
IVsThreadedWaitDialogFactory factory = (IVsThreadedWaitDialogFactory)await VS.Services.GetThreadedWaitDialogAsync();
- 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.

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