2014-11-03 3 views
1

일부 시각적 스튜디오 확장 프로그램을 만들고 솔루션 폴더를 프로그래밍 방식으로 만듭니다. 그러나 다른 솔루션 폴더에서 종속성 솔루션 폴더를 만드는 방법을 모르겠습니다. 이 문제와 관련하여 도움이 될 수 있습니까? 감사!솔루션 폴더의 종속성

|--- SolutionFolder 
|   |--- SolutionFolder 
|   |--- SolutionFolder 
|--- SolutionFolder 

여기 내 코드입니다 :

(object sender, EventArgs args) => 
{ 
    Guid slnFldrGuid = new Guid("2150E333-8FDC-42A3-9474-1A3956D46DE8"); 
    Guid iidProject = typeof(IVsHierarchy).GUID; 

    IVsSolution solution = GetService<IVsSolution, SVsSolution>(); 
    IVsHierarchy parent = UIShellUtilities.GetSelectedHierarchy(); 
    IVsHierarchy nested = null; 

    IntPtr project = IntPtr.Zero; 
    int canceled = 0; 

    if ((null != solution) && (null != parent)) 
    { 
     IVsProjectFactory factory = null; 

     ErrorHandler.ThrowOnFailure(solution.GetProjectFactory(
      0, new Guid[] { slnFldrGuid }, null, out factory)); 

     try 
     { 
      ErrorHandler.ThrowOnFailure(factory.CreateProject(
       null, null, "New My Folder", 0, ref iidProject, out project, out canceled)); 

      if (project != IntPtr.Zero) 
      { 
       nested = Marshal.GetTypedObjectForIUnknown(project, typeof(IVsHierarchy)) as IVsHierarchy; 

       Debug.Assert(nested != null, "Nested hierarchy could not be created"); 
       Debug.Assert(canceled == 0); 
      } 
     } finally 
     { 
      if (project != IntPtr.Zero) 
       Marshal.Release(project); 
     } 

     uint itemid = VSConstants.VSITEMID_ROOT; 

     // Link into the nested VS hierarchy. 
     //ErrorHandler.ThrowOnFailure(nested.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ParentHierarchy, parent)); 
     //ErrorHandler.ThrowOnFailure(nested.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid, (object)itemid)); 
    }       
} 

답변