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.

No code example is currently available or this language may not be supported.

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.

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.

No code example is currently available or this language may not be supported.

The ComVisibleAttribute is required to obtain the interface from unmanaged code.

System_CAPS_noteNote

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.

Show: