This project is read-only.

Where did the Workspace.PrimaryWorkspace property go ?

Topics: APIs, C# Language Design, General
May 10, 2014 at 8:57 AM
I am new to Roslyn. I have got the Microsoft.CodeAnalysis from Nuget Gallery.

I've been reading all over the place about Workspace.PrimaryWorkspace property. But I can't find it anywhere.

I am trying to get the reference of Workspace object from IVsSolution object. I am writing a VSPackage project.

Any help is appreciated
May 13, 2014 at 7:54 PM
The primary workspace was removed from the general API because the concept of a primary only existed in certain scenarios, like running within VS.

You can still get to the VS workspace, however.

From your Package class you can get IComponentModel, VS's magic entry point for MEF.

var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel));

and then from the componentModel you can get the exported VisualStudioWorkspace.

var vsWorkspace = componentModel.GetService<VisualStudioWorkspace>();