I am trying to build a VSIX-package for vs2017 to make a customtool available. The problem i am facing now is that i am unable to get the current workspace while debugging. The following code is used to get the workspace:
var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
var workspace = (Workspace)componentModel.GetService<VisualStudioWorkspace>();
The error thrown in the second line of code is "Unable to cast object of type 'Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace' to type 'Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace'.".
I already added the languageservices-package to the project as suggested on other threads.
This would happen if you have two different versions of the Roslyn DLLs loaded (you can check that in Debug, Modules).
Make sure that the references to Roslyn in your VSIX project are not set to Copy Local or to Include in VSIX.