OSCAR_NJU

奔向远方,希望不会错过沿途的风景。。。
  博客园  :: 首页  :: 新随笔  :: 订阅 订阅  :: 管理

VS2005自动注册控件方法一

Posted on 2008-03-11 09:09  OSCAR_NJU  阅读(1240)  评论(0编辑  收藏  举报

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:

  1. 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
  2. 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\
  3. 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

http://blogs.msdn.com/chetanc/archive/2005/10.aspx