安装vs.net 2003后提示"Dte.olb could not be loaded.Please re-run setup and repair your installat

类别:.NET开发 点击:0 评论:0 推荐:

安装vs.net 2003后提示"Dte.olb could not be loaded.Please re-run setup and repair your installation"而无法启动vs.net
(wellknow发表于2004-8-24 17:19:13)

          通过搜索,发现DTEv.olb位于X:\Program Files\Common Files\Microsoft Shared\MSEnv内
        使用regsvr32手动注册一下,IDE可以正常启动。查了一下MSDN,有相应文章说明

        =============================================================================
        PRB: Visual IDE Does Not Open When Started or Application Cannot Start Error Message
        http://support.microsoft.com/default.aspx?scid=kb;EN-US;306905
        那么这个文件是做什么的呢?
        查看msdn内容如下地址:
        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebugext/html/vxlrfenvdtedebugger.asp
        它包含EnvDTE 名字空间,assembly 名称是envdte。
        Visual Studio .NET的所有对象、成员和自动化模型都是基于DTE对象. DTE对象代表 Visual Studio .NET IDE ,它位于自动化模型类的顶级.
        包含在envdte.dll中。COM 类型库名称是 "Microsoft Development Environment 7.0" 就被包含在dte.olb中.
        简单一句话,它就代表IDE,我们可以用它来扩展VS.net IDE
        因为所有自动化对象都要求DTE对象,所以如果没有正确注册,IDE肯定无法正常工作。
        顺便说说我没自己如何添加它的引用。
        选择.NET assembly 还是COM依靠工程类型。(如果你使用add_ins向导或宏,那么不需要你手动添加引用,但是如果你是在外部使用,那么你必须手动添加引用)
        引用的方法就是从”解决方案(Solution Explorer)“中通过”添加引用(Add Reference)“来加入envdte"或者 " Microsoft Development Environment 7.0"
        (以上是vb和c#的方法。)
        一个具体使用的例子:

        Programmatically Adding a UserControl to the VS.NET ToolBox
        作者:Shawn A. Van Ness
        例子演示将Microsoft Tablet PC SDK的InkPicture 和 InkEdit添加到VS.NET 的Toolbox
        private static void AddToolBoxTab(EnvDTE.DTE env)
        {
        // First, ensure Tablet SDK is installed -- get location of Microsoft.Ink.dll
        string fullpathToMicrosoftInk = LookupMicrosoftInkAssemblyFilename();

        // Prepare to munge the toolbox -- get toolbox window, object, and tabs collection
        EnvDTE.Window toolboxWindow = env.Windows.Item(EnvDTE.Constants.vsWindowKindToolbox);
        EnvDTE.ToolBox toolbox = (EnvDTE.ToolBox)toolboxWindow.Object;
        EnvDTE.ToolBoxTabs toolboxTabs = toolbox.ToolBoxTabs;

        // Careful to check if our tab already exists
        foreach (EnvDTE.ToolBoxTab tab in toolboxTabs)
        {
        if (tab.Name == TabName)
        return;
        }

        // No, so add it
        EnvDTE.ToolBoxTab newtab = toolboxTabs.Add(TabName);

        // WinBug: gotta show the Properties window, first (this cost me ~1 day of my life)
        env.ExecuteCommand("View.PropertiesWindow", "");

        // WinBug2: gotta activate the tab and select the first item (grr...)
        newtab.Activate();
        newtab.ToolBoxItems.Item(1).Select();

        // Finally: add the Microsoft Ink controls
        newtab.ToolBoxItems.Add(
        @"Unused?",
        fullpathToMicrosoftInk,
        EnvDTE.vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent
        ;
        }

        private static string LookupMicrosoftInkAssemblyFilename()
        {
        Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine;
        rk = rk.OpenSubKey(KeyName, false);

        if (rk == null)
        throw new ArgumentException(String.Format("Could not find registry key:\n[HKLM\\{0}]",KeyName));

        string fullpathToAssembly = (string)rk.GetValue(null);
        fullpathToAssembly += @"\Microsoft.Ink.dll";

        if (!System.IO.File.Exists(fullpathToAssembly))
        throw new System.IO.FileNotFoundException("File not found", fullpathToAssembly);

        return fullpathToAssembly;
        }

        MSDN 提供的例子
        Visual Studio .NET 2003 Automation Samples

        http://www.microsoft.com/downloads/details.aspx?familyid=3FF9C915-30E5-430E-95B3-621DCCD25150&displaylang=en

注册命令:
C:\Program Files\Common Files\Microsoft Shared\MSEnv>regsvr32 dte.olb

本文地址:http://com.8s8s.com/it/it44386.htm