共用方式為


ServiceProvider.CreateFromSetSite(IServiceProvider) Method

Definition

Create a new ServiceProvider for the given site.

public:
 static Microsoft::VisualStudio::Shell::ServiceProvider ^ CreateFromSetSite(Microsoft::VisualStudio::OLE::Interop::IServiceProvider ^ sp);
public static Microsoft.VisualStudio.Shell.ServiceProvider CreateFromSetSite (Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp);
static member CreateFromSetSite : Microsoft.VisualStudio.OLE.Interop.IServiceProvider -> Microsoft.VisualStudio.Shell.ServiceProvider
Public Shared Function CreateFromSetSite (sp As IServiceProvider) As ServiceProvider

Parameters

sp
IServiceProvider

The OLE service provider

Returns

The service provider.

Remarks

This method should be called from an object that implements SetSite() (for example, IObjectWithSite or IVsPackage). It sets the global service provider if it hasn't already been set.

This method is typically called from the SetSite() method of a VSPackage.

Note

By calling this method, the caller declares that it knows the global OLE service provider for the calling thread and that the service provider instance returned may be used by other, unrelated components, accessed via the GlobalProvider static property.

Applies to