Using the Tools.InstallCommunityControls command
Copy files
Copy the controls to the My Documents\Visual Studio 2005\Controls\<companyname>\ folder. The <companyname> is used as the name of the tab which will contain controls.
Execute Command:
Open the Visual Studio Command prompt and execute the following command:
devenv /command Tools.InstallCommunityControls
使用批处理:
set TabName=GDK
set DllName="WinCETools.Client.dll"
set ControlsFolder="%userprofile%\My Documents\Visual Studio 2005\Controls\%TabName%"
mkdir %ControlsFolder%
copy %DllName% %ControlsFolder%
pause
"%VS80COMNTOOLS%\..\IDE\devenv.exe" /command Tools.InstallCommunityControls
pause
编程实现:using DTE is to use DTE.ExecuteCommand
DTE2 dte;
dte = (DTE2)Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.DTE.8.0"));
dte.ExecuteCommand("Tools.InstallCommunityControls", "");
dte.Quit();
注意事项:
1、Tools.InstallCommunityControls 执行不成功
Failure to install Toolbox controls via ContentInstaller or Tools.InstallCommunityControls
If you have the SQL Server Management Studio Express CTP or SQL Server 2005, then it is overwriting some registry key settings. The workaround for this is:
- Under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{36839529-3AF3-47fa-8194-F4A3FA9F0ED7}, change the CodeBase value to use the Visual Studio 8.0 location, for e.g. file:///D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.VisualStudio.ToolBoxControlInstaller.dll
- Under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{36839529-3AF3-47fa-8194-F4A3FA9F0ED7}\SatelliteDll, change the Path value to point to the Common7\IDE folder for e.g. D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\
- Open the Visual Studio Command Prompt and run devenv /setup
This should fix the issue.
2、注册后可以在注册表看到
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\UserToolBoxControls\
下看到新的“选项卡”(TabName)名称
3、可以重复执行命令
4、在执行命令之前务必先关闭所有VS2005 IDE,否则注册后的设置会被IDE的关闭操作覆盖
5、执行不成功最可能的原因是Controls目录下有非可注册的dll或者其他文件存在,切记!!!
参考资料:
http://blogs.msdn.com/chetanc/archive/2005/11/16/493495.aspx
http://blogs.msdn.com/chetanc/archive/2005/10/05/477128.aspx