2010-12-20 2 views
2

작성한 사용자 지정 SSIS 구성 요소의 설치 관리자를 만듭니다. 사용자가 수동으로 추가하도록 요청하는 대신 자동으로 사용자 지정 구성 요소를 추가하고 싶습니다.프로그래밍 방식으로 Visual Studio 도구 상자에 사용자 지정 구성 요소를 추가하는 방법?

public void AddToolboxItem(string toolboxTabName, string toolBoxItemName, string toolBoxItemPath) { 
    Type dteReference; 
    EnvDTE.ToolBox toolBox; 
    EnvDTE80.ToolBoxItem2 addedToolBoxItem; 

    // Get a reference to the visual studio development environment. 
    dteReference = Type.GetTypeFromProgID("VisualStudio.DTE.9.0"); 

    if(dteReference != null) { 
    // Get a reference to the toolbox of the development environment. 
    EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)Activator.CreateInstance(dteReference); 
    toolBox = (EnvDTE.ToolBox)dte.Windows.Item("{B1E99781-AB81-11D0-B683-00AA00A3EE26}").Object; 

    // Loop through all tab pages to find the toolbox tab page that was specified 
    // in the toolboxTabName parameter. 
    foreach (EnvDTE80.ToolBoxTab2 toolBoxTab in toolBox.ToolBoxTabs) { 

     // Is this the right toolbox? 
     if(string.Compare(toolBoxTab.Name, toolboxTabName, true) == 0) { 

     // First check if the component is not already in the toolbox: 
     bool found = false; 
     foreach(EnvDTE80.ToolBoxItem2 toolBoxItem in toolBoxTab.ToolBoxItems) { 
      if (string.Compare(toolBoxItem.Name, toolBoxItemName, true) == 0) { 
      found = true; 
      break; 
      } 
     } 

     // The toolbox item is not in the toolbox tab, add it: 
     if (!found) { 
      addedToolBoxItem = (EnvDTE80.ToolBoxItem2)toolBoxTab.ToolBoxItems.Add(
      toolBoxItemName, 
      toolBoxItemPath, 
      EnvDTE.vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent); 
     } 
     break; 
     } 
    } 
    } 
} 

내가 "데이터 흐름 변환"도구 상자 탭에 대한 참조를 얻을 수 있지만 항목을 추가하면 예외 나 오류없이 실패

는이 코드로이 작업을 수행하기 위해 노력하고있어.

나는 매개 변수와 함께이 함수를 호출 :

  • toolboxTabName = "데이터 흐름 변환"
  • toolBoxItemName = "특별 시험 구성 요소"
  • toolBoxItemPath = "C : \ 프로그램 Files \ Microsoft SQL 서버 \ 100 \ DTS \를 PipelineComponents \ mdTest.dll "전성 검사로서

, I 부가()의 세번째 파라미터로 vsToolBoxItemFormatDotNETComponent 열거하여 시도. 이렇게하면 Add가 올바른 개체 (즉, 성공)를 반환하지만 새 항목은 도구 상자에 나타나지 않습니다. Add()가 제대로 작동하더라도 필요한 '저장'작업이 필요하다고 생각합니다.

도구 상자에 프로그래밍 방식으로 SSIS 구성 요소를 추가하는 방법이 있습니까?

+0

모든 도구는 사용자가 도구 상자에 DLL을 끌어 만들었습니다. 어쩌면 당신은 이것을 깨뜨린 첫 번째가 될 것입니다. – Sam

+0

SQL Server 2012를 설치할 때 VS2010에 설치된 새 BIDS가 PipelineComponents의 모든 구성 요소를 자동으로 설치합니다. 이 문제는 SQL Server 2012에서는 문제가되지 않습니다. –

답변

3

같은 질문은 MSDN 포럼에서도 찾을 수 있으며 MVP, 사회자가 답변 해주었습니다. MSDN 포럼에 제공된 답변에 대한 링크를 붙여서이 질문에 걸림돌이되는 다른 사람들이 대답을 알 수 있도록합니다. 내가 설치 한

Programmatically Add an SSIS Component to the Toolbox(social.msdn.microsoft.com)

+0

그래, 그게 내 질문이야. 때때로 인터넷은 작은 세계 일 수 있습니다. –

관련 문제