views:

31

answers:

1

The Visual Studio 2010 SDK ships with many assemblies like Microsoft.VisualStudio.Text.Data and Microsoft.VisualStudio.Text.UI that are just stubs. To write an extension for Visual Studio, you reference these assemblies, but set "Copy Local" and "Exact Version" properties of the references to false. When your extension is loaded in Visual Studio, the references are bound to Visual Studio's previously loaded internal implementation of these assemblies.

I'd like to provide a new MEF exported component that acts as a Visual Studio service that other MEF packages can [Import]. To use the service, the other components will need to reference my package - but I prefer for them to reference a stub so I can make changes to the internal implementation of my service without breaking other packages that reference it. How can I provide a "stub" assembly containing the publicly visible API components from some arbitrary assembly, such that if you reference the stub it will seamlessly work with the provided implementation at runtime?

A: 

I solved this problem by creating two assemblies:

  • MyCompany.VisualStudio.Feature: Interfaces and in some cases abstract classes to simplify the most common implementations. No [Export]s in here.
  • MyCompany.VisualStudio.Feature.Implementation: Implements services related to the feature. Here you'll see the [Export]s.

People using my feature just reference the former, and set Copy Local and Exact Version to false.

280Z28