***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***
In the previous post we covered the details of the Microsoft.VisualStudio.ComponentModelHost.IComponentModel service
Now it’s time to talk about the Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost, which is the other service that is proffered by the host package.
Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service
This service has the following responsibilities:
- Get the catalog cache folder
- Get MEF component locations
The catalog cache folder is located @ %LocalAppData%\Microsoft\VisualStudio\10.0\ComponentModelCache.
The Microsoft.VisualStudio.ExtensionManager.IVsExtensionManager service
To query extensions locations the IVsExtensionManager service is used. To filter only MEF component extensions, the “MEFComponent” content type in the VSIX extension manifest is used.
This service has many responsibilities which I will cover in future posts, but the one I will describe is:
- Get enabled extension locations
To get the list of enabled extension locations Visual Studio looks in the following folders:
- %LocalAppData%\Microsoft\VisualStudio\10.0\Extensions
- %VS10_Install_Dir%\Extensions
- %VS10_Install_Dir%\Common7\IDE\Extensions
- %VS10_Install_Dir%\Common7\IDE\CommonExtensions
The first location is where VSIX files are deployed once you double a VSIX file from the Windows explorer shell.
The other locations are being used Visual Studio core extensions and to deploy a VSIX file under those locations you will need administrator privileges.
Stay tuned,
Pablo
***Disclaimer: This information applies to Visual Studio 2010 Beta 1 only.***
These series of posts will cover two types of Visual Studio 10 Beta 1 extensions:
- MEF component (assembly that contains exports and imports)
- VSPackage
In the previous post we said that Visual Studio is a host for MEF components. This is being done by the introduction of a new VS core package called Microsoft.VisualStudio.ComponentModelHost.HostPackage
The host package is declares the following two core services:
- Microsoft.VisualStudio.ComponentModelHost.IComponentModel service
- Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service
Microsoft.VisualStudio.ComponentModelHost.IComponentModel service
This service has the following responsibilities:
- Get MEF catalog by name
- Get MEF export / exports
- Creates and maintains a list of available catalogs
- Declares the GlobalCompositionContainer
The VsCatalogProvider, AssemblyListCatalog and VSCatalogName classes:
The GetCatalog method returns a catalog by name by searching the list of available catalogs that is maintained by the service itself.
If the catalog doesn’t exist it is created and then added to the list. To create a catalog the Microsoft.VisualStudio.ExtensibilityHosting.VsCatalogProvider class is used. This class has the following responsibility:
- Build and return an AssemblyListCatalog
The Microsoft.VisualStudio.ExtensibilityHosting.AssemblyListCatalog class derives from the MEF ComposablePartCatalog and it is basically a list of AssemblyCatalogs.
The AssemblyListCatalog is constructed by adding every MEF component assembly found in the system filtered by the catalog name. To find the MEF component assemblies, the Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service is used.
To specify a catalog name for a MEF component assembly there is a VsCatalogName attribute:
[assembly: VsCatalogName("Microsoft.VisualStudio.Editor")]
Multiple MEF composition containers:
Visual studio supports multiple MEF composition containers. A core component is responsible for creating its own container. For example the Visual Studio editor creates its own container. There is a service that maintains the list of available containers and it is the Microsoft.VisualStudio.ExtensibilityHosting.VsExportProviderService class.
The GlobalCompositionContainer:
The GlobalCompositionContainer acts as the root MEF composition container. This container is used by the IComponentModel service to get MEF export / exports.
Behind the scenes the GlobalCompositionContainer uses the VsExportProviderService to search in all available containers.
The VsCompositionContainer class:
A container in Visual Studio derives from the MEF CompositionContainer class and adds features such as export providing settings, export sharing policies, export provisioning scope, etc. And it modeled by the Microsoft.VisualStudio.ExtensibilityHosting.VsCompositionContainer class
In the next post I will cover the details for the Microsoft.VisualStudio.Shell.Interop.IVsComponentModelHost service.
Pablo