Share via


IVsProjectStartupServices.AddStartupService Method

Adds third party service to the list of services to be started when the project is instantiated and ensures that all third party services are started.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

Syntax

'Declaration
Function AddStartupService ( _
    ByRef guidService As Guid _
) As Integer
int AddStartupService(
    ref Guid guidService
)
int AddStartupService(
    [InAttribute] Guid% guidService
)
abstract AddStartupService : 
        guidService:Guid byref -> int 
function AddStartupService(
    guidService : Guid
) : int

Parameters

  • guidService
    Type: System.Guid%
    [in] GUID object specifying service.

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsProjectStartupServices::AddStartupService(
   [in] REFGUID guidService
);

Your implementation of IVsProjectStartupServices.AddStartupService stores the service GUID, then starts it and maintains a pointer to it. You must store any added GUIDs in your project file and read them back in and start the services during project initialization. When your project hierarchy class terminates, you must stop the services, which is accomplished by implementing RemoveStartupService to release the pointers you held.

This functionality is not provided in HierUtil7's CVsHierarchy, which is the basis for Basic Project's CMyProjectHierarchy, so the interface is implemented in the Basic Project sample. The implementation of the above behavior in Basic Project is contained within a member variable to the hierarchy (m_projectStartupServices), which adds the code it takes to remember the services, and start/stop them. The m_projectStartupServices class member is implemented in CVsProjectStartupServices in the file VsProjectStartupServices.h/.cpp, which you can analyze to get an example of proper implementation.

nulla null reference (Nothing in Visual Basic) GUIDS are not added to the list.

.NET Framework Security

See Also

Reference

IVsProjectStartupServices Interface

Microsoft.VisualStudio.Shell.Interop Namespace