Reference.Services Sample

This sample shows how to be a Visual Studio service provider and how to consume Visual Studio services.

 
 
 
 
 
(0)
4,957 times
Add to favorites
2/22/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

VB.NET
C#
C#, C++
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="../../../../Common/Overview.xsl" type="text/xsl"?>
<VSSDKSample>
  <ImagePath>../../../../Common</ImagePath>
  <Status>
    <Accessibility>true</Accessibility>
    <ArchitectureDiagram>true</ArchitectureDiagram>
    <Comments>true</Comments>
    <Documentation>true</Documentation>
    <ErrorHandling>true</ErrorHandling>
    <FollowSDKCodingStandards>true</FollowSDKCodingStandards>
    <Localizable>true</Localizable>
    <Overview>true</Overview>
    <ScenarioTests>true</ScenarioTests>
    <Supported>true</Supported>
    <UnitTests>true</UnitTests>
    <Style>Reference</Style>
  </Status>
  <Overview>
    <ShortName>C++ Reference.Services</ShortName>
    <LongName>C++ Services Reference Sample</LongName>
    <Phrase>Creating, exposing, and consuming services in Visual Studio using C++.</Phrase>
  </Overview>
  <Introduction>
    <Summary>
      This sample shows how to be a Visual Studio service provider and how to consume Visual Studio
      services.
    </Summary>
    <Goal>Creating and Proffering services in Visual Studio</Goal>
    <Goal>Consuming services in Visual Studio</Goal>
    <Goal>Local versus Global services</Goal>
    <Image width="400" height="400">Services.jpg</Image>
  </Introduction>
  <SampleInfo>
    <State>
    </State>
    <Type>Reference</Type>
    <Complexity>1</Complexity>
    <Screenshot>Services.jpg</Screenshot>
    <Area>IDE</Area>
    <Language>C++</Language>
    <Folder>VisualStudioIntegration\Samples\IDE\CPP\Reference.Services\</Folder>
    <SampleSolution>Services.sln</SampleSolution>
    <FolderUnitTest>VisualStudioIntegration\Samples\IDE\CPP\Reference.Services\UnitTest\</FolderUnitTest>
    <UnitTestStartup>ServicesUnitTest.vcproj</UnitTestStartup>
    <Doc />
    <Keywords>
      <Keyword>Local service</Keyword>
      <Keyword>Global service</Keyword>
      <Keyword>Consuming</Keyword>
      <Keyword>Service</Keyword>
      <Keyword>Services</Keyword>
      <Keyword>Creating</Keyword>
      <Keyword>Proffering</Keyword>
    </Keywords>
  </SampleInfo>
  <GettingStarted>
    <Paragraph>
      The sample contains three main classes.  A service provider package called ServiceProviderPackage,
      a service consumer package called ServiceConsumerPackage, and a local service provider called
      LocalServiceProvider, which belongs to the service provider package.
    </Paragraph>
    <Paragraph>
      ServiceProviderPackage registers its service in the Visual Studio registry so that it will be
      loaded when any package queries for the service. In this sample ServiceConsumerPackage will
      do this.  Additionally, ServiceProviderPackage offers this service to Visual Studio when it is
      loaded. Simply registering the service in the Visual Studio registry is insufficient to allow a
      client to successfully query for it.
    </Paragraph>
    <Paragraph>
      ServiceConsumerPackage registers its menu and provides three menu items on the Visual Studio Tools
      menu entitled:
    </Paragraph>
    <Paragraph>"VSSDK C++ Execute Global Service"</Paragraph>
    <Paragraph>"VSSDK C++ Execute Local Service"</Paragraph>
    <Paragraph>"VSSDK C++ Execute Local using Global Service"</Paragraph>
    <Paragraph>
      The command handlers for these menu items are provided by ServiceConsumerPackage. Each handler
      attempts to query for either the globally offered service provided by ServiceProviderPackage
      or the local service provided by ServiceProviderPackage.  Querying for the local service is
      expected to fail.  Utilizing each menu item will cause a text string to be sent to the Output
      window. (NOTE - There is a bug in the Output window. If you don't see the text, then simply restart Visual Studio).
    </Paragraph>
  </GettingStarted>
    <BuildingTheSample>
    <Step>
      Open the Package.sln solution.
	</Step>
	<Step>
	  Right-click the ServicesTest project and choose <bold>Set as Startup Project</bold>.
    </Step>
    <Step>
      Press F5 to build the sample, register it in the experimental instance, and launch Visual Studio from the experimental instance.
    </Step>
  </BuildingTheSample>
  <AdditionalResources>
    <Resource>
      <Title>Visual Studio SDK Website</Title>
      <URL>http://msdn.microsoft.com/vstudio/extend</URL>
    </Resource>
  </AdditionalResources>
  <UnitTests>
    <Test>
      Call the three command handlers of ServiceConsumerPackage after creating and siting both
      ServiceConsumerPackage and ServiceProviderPackage.
    </Test>
  </UnitTests>
  <FunctionalTests>
    <Test>
      Sample builds without errors and warnings in both Debug and Release configurations.
    </Test>
    <Test>
      Registration is appropriately entered under the experimental instance.
    </Test>
    <Test>
      After registration in the experimental Visual Studio hive by
      calling 'Devenv /rootsuffix Exp /setup', execute all 3 of the commands on the Tools menu and validate the outputs in the Output window.
    </Test>
    <Test>
      Registration is appropriately entered under the standard Visual Studio registry hive when 
      regsrv32.exe is used to register the DLL.
	</Test>
  </FunctionalTests>
  <ProjectFiles>
    <File>
      <Name>LocalServiceProvider.h</Name>
      <Description>
        Implementation for LocalServiceProvider.
      </Description>
    </File>
    <File>
      <Name>ServiceConsumerPackage.h</Name>
      <Description>
        Implementation for ServiceConsumerPackage.
      </Description>
    </File>
    <File>
      <Name>ServiceProviderPackage.h</Name>
      <Description>
        Implementation for ServiceProviderPackage.
      </Description>
    </File>
    <File>
      <Name>ServicesUnitTest.cpp</Name>
      <Description>
        Unit tests for this sample.
      </Description>
    </File>
  </ProjectFiles>
  <History>
    <Change>
      <Date>2009-03-26</Date>
      <Description>Created this sample for the Visual Studio 2010 SDK.</Description>
    </Change>
  </History>
</VSSDKSample>