Provides a unified service provider for managed VSPackages.
Assembly: Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
Thetype exposes the following members.
|ServiceProvider(IServiceProvider)||Initializes a instance with an existing IServiceProvider interface.|
|ServiceProvider(IServiceProvider, Boolean)||Initializes a new instance of the class with an existing IServiceProvider object and optionally passes all requests to the underlying service provider.|
|CreateFromSetSite||Create a new ServiceProvider for the given site.|
|Dispose||Releases the resources used by the object.|
|Equals||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetService(Guid)||Gets the specified service from the unmanaged service provider.|
|GetService(Type)||Gets type-based services from the unmanaged service provider.|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
This class supports both GUID and type based lookups. It also checks for common native implementation pitfalls, such as objects that do not implement the IUnknown interface or that require a specific IID along with a matching SID.
This class also provides debugging support in the debug version of the .NET Framework (also known as a "checked" version). Setting the tracing switch TRACESERVICE to TraceVerbose causes all service requests to be output to the debug listener.
In addition, tests for certain conditions when forwarding a service request to native code. Managed code requires the IUnknown interface when resolving services, but most native queries do not. If an unmanaged service cannot be obtained through an IID of IUnknown, an additional call is made in checked builds with the SID used in place of the IID. raises an assert if the SID query succeeds.
Returning the result of a successful SID query in a checked build causes a different behavior in the debug and retail builds of the VSPackage, so an assert is raised instead.
In addition to translating service requests to the COM service provider, the class offers the following non-replaceable services:
Provides access to the native COM service provider object. The service provider object can be used to directly query for other interfaces.
Provides a way to replace the COM service provider. In many places within Visual Studio an object is first given one site, and later another, more localized site. The more localized site can be passed through to the service provider's IObjectWithSite implementation to create a single point of contact for services. (The SetSite method is ignored if the site does not implement IServiceProvider.)