Newbie Request - Custom Project Type, Managed Code, VS 2003

Hi -

We are beginning to look at the VSIP program.  We need to implement a new
custom project type and would prefer to do this in C#.  Our customer
requirements dictate that we need to come up with a solution that works in
both VS 2003 and 2005.  Later on, we'll be able to target 2005, but for now,
we need to stick with what works in 2003.  I've downloaded the VSIP SDK
Extras for 2003 and looked at the managed package samples - there is no
example for adding a custom project type.  Does anyone have or know of a
good, basic, working VSIP 2003 sample that implements a custom project type
in managed code   (Including the portions that needed to be coded native )

Thanks very much for your help.

JPBlake



Answer this question

Newbie Request - Custom Project Type, Managed Code, VS 2003

  • Tahir275

    Hi,
    There is not sample for 2003 if you want to implement a project system in C# you need to do the following things:


    C#
    - Create your project class, in general you should implement several interfaces. Make the object visible for COM


    [Guid(yourProjectGUID)]public class Project ...

    - Create a COM object that implements IObjectWithSite
    In the SetSite implementation aggregate the COM object with your Project.

    CoCreateInstance(yourProjectGUID, this, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**) &m_managedProject);

    In the QueryInterface implementation

    virtual HRESULT _InternalQueryInterface( REFIID riid,LPVOID FAR* ppvObject)
    {
       if (riid == IID_IUnknown || riid == IID_IObjectWithSite )
       {
          AddRef();
          *ppvObject =
    this;
          return S_OK;
       }
       if (m_managedProject && SUCCEEDED(m_managedProject->QueryInterface(riid,    ppvObject)))
       {   
             return S_OK;
       }
       return E_NOTIMPL;
    }

    - The last step is create the COM object in your factory

    public int CreateProject(string fileName, string location, string name, uint grfCreateFlags, ref System.Guid idProject

    , out IntPtr project, out int canceled)

    {

    // Create the COM aggregator class
    MyProjectWrapperLib.ProjectWrapperClass cls = new ProjectWrapperClass();

    Microsoft.VisualStudio.OLE.Interop.IObjectWithSite st = cls as Microsoft.VisualStudio.OLE.Interop.IObjectWithSite;

    st.SetSite(Package.PackageSite);
    project = Marshal.GetIUnknownForObject(cls);
    canceled = 0;

    return NativeMethods.S_OK;

    }



  • Santito

    Gaston,

    I'm working on a managed custom project type (in c#) with VSIP.
    I must have my package to work with VS2003 and VS2005.

    Actually, my package works well in VS2005 (beta2) but in VS2003, I have a few subtle problems with the Project Properties window.
    Probably, this wrapper can fix these problems.

    Unfortunately, I don't know how to do this.
    Would you be able to point me to an example or to a few tips about how to do it

    Thanks in advance,

    Kind regards,

    Jean-Sebastien


  • Newbie Request - Custom Project Type, Managed Code, VS 2003