私が作成したカスタム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:\ Program Files \ MicrosoftのSQLサーバ\ 100 \ DTS \ PipelineComponents \ mdTest.dll」
健全性チェックとして、私は、追加()の三番目のパラメータとしてvsToolBoxItemFormatDotNETComponent列挙を使用してみました。これにより、有効なオブジェクト(つまり成功)が返されますが、新しい項目はツールボックスに表示されません。私は必要があるかもしれない何らかの「保存」操作があると思う(たとえAdd()が正しく機能するようになっても)。
ツールボックスにSSISコンポーネントをプログラムによって追加する方法はありますか?
私がインストールしたすべてのツールは、ユーザーがツールボックスにDLLをドラッグしてきました。たぶんあなたはこれを解読した最初の人になるでしょう:) – Sam
SQL Server 2012のインストール時にVS2010にインストールされる新しいBIDSは、PipelineComponentsのすべてのコンポーネントを自動的にインストールします。これはSQL Server 2012の問題ではありません。 –