Deploying Managed-Code Project Types

Visual Studio SDK installs a new project-type aggregator (ProjectAggregator2.dll) and also a Windows Installer package for redistribution (ProjectAggregator2.msi). You must use the new aggregator for managed-code project types. ProjectAggregator2 works arounds limitations in the Visual Studio 2008 project aggregator that prevent managed-code project types from working correctly. The following steps describe how to change your VSPackage to use the new aggregator.

  1. Remove the NativeHierarchyWrapper project from your solution.

  2. Remove any NativeHierarchyWrapper binaries from your setup.

  3. Add ProjectAggregator2.msi to your setup. For more information, see Visual Studio SDK Redistributable Components.

If you based your project on the ProjectSubtype sample in <Visual Studio SDK installation path>\VisualStudioIntegration\Archive\CS_Samples\ProjectSubtype\, make the following changes also:

  • Remove any reference to Microsoft.VisualStudio.ProjectAggregator.dll.

  • Add to your project the following files from <Visual Studio SDK installation path>\VisualStudioIntegration\Common\Source\CSharp\Project\:

    • AggregatableProjectInterops.cs

    • FlavoredProjectBase.cs

    • FlavoredProjectFactoryBase.cs

    • ProjectAggregator2Interops.cs

  • Add the following attributes to your project class:

    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    
  • Derive your project class from FlavoredProjectBase instead of FlavoredProject.

  • Change the SetInnerProject method of your project class to have the following signature:

    protected override void SetInnerProject(IntPtr innerIUnknown)
    
  • Add the following code to the start of the SetInnerProject method of your project class:

    object inner;
    inner = Marshal.GetObjectForIUnknown(innerIUnknown);
    base.SetInnerProject(innerIUnknown);
    
  • Remove the following code from the SetInnerProject method of your project class:

    // Now let the base implementation set the inner object
    base.SetInnerProject(inner);
    
  • Derive your project factory class from FlavoredProjectFactoryBase instead of FlavoredProjectFactory.

  • Change the PreCreateForOuter method of your project factory class to have the following signature:

    protected override object PreCreateForOuter(IntPtr outerProjectIUnknown)
    
  • Examine the changes that were made to the sample's ProjectFactory.PreCreateForOuter, SpecializedProject.Close, and SpecializedCfg.Close methods to determine the changes you should make to your own project classes.