How to: Register a Service
The managed package framework (MPF) provides attributes to control the registration of managed services. The RegPkg utility uses these attributes to register a service with Visual Studio.
Example
The code that follows is from VSSDK Samples.
Robust Programming
To make it easier to recompile a service provider without changing the service client, or vice versa, you can define the service and its interfaces in a separate assembly module. The following code is from the IMyGlobalService.cs file in the Reference.Services (C#) sample.
The ComVisibleAttribute is required to obtain the interface from unmanaged code.
Note |
|---|
Although you could use the same type or GUID for both the service and the interface, we recommend that you separate the two because a service can expose different interfaces. |

The ProvideServiceAttribute registers the SMyGlobalService service with Visual Studio. For more information about DefaultRegistryRootAttribute and PackageRegistrationAttribute, see Registering and Unregistering VSPackages.
To register a service that replaces another service with the same name, use the ProvideServiceOverrideAttribute instead of the ProvideServiceAttribute.