none
Recorded macro does not run; Failing on DTE.ExecuteCommand("File.ViewinBrowser")

    Question

  •  

    Hi,

     

    I recorded a macro to open 2 files from 2 different projects in the browser; it generated:

    Code Snippet

    DTE.ToolWindows.SolutionExplorer.GetItem("Product\Server\WebService1\Facade.asmx").Select(vsUISelectionType.vsUISelectionTypeSelect)

    DTE.ExecuteCommand("File.ViewinBrowser")

    DTE.ToolWindows.SolutionExplorer.GetItem("Product\Server\WebService2\Facade.asmx").Select(vsUISelectionType.vsUISelectionTypeSelect)

    DTE.ExecuteCommand("File.ViewinBrowser")

     

     

     

    But when I run this macro, it fails with the following error:

    Error HRESULT E_FAIL has been returned from a call to a COM component.

     

    When debugging the code, it is clear that the DTE.ExecuteCommand("File.ViewinBrowser") is throwing the error.

     

    The goal is to start up the ASP.NET Development Server, (2 instances) so when I run the application, the webservices are ready to run. (I do not want to use the Solution > Properties > Startup Project >Mutlitple startup projects option)

     

    Any help is appreciated.

     

    ps: I also recorded a macro for another purpose, which attempts to execute DTE.ExecuteCommand("Project.Run") but that also fails. (This is a command that only becomes available when adding a Database project in VS Professional, using Other Project Types > Database)

    Thursday, April 10, 2008 3:23 PM

Answers

All replies

  • Could you please clarify the version of Visual Studio you're talking about and the detailed steps to reproduce this issue?
    Monday, April 14, 2008 5:35 AM
  • Hi,

     

    I'm using Visual Studio 2005 (below is the full list taken from the About window).

    To reproduce:

    1) Create a new C# ASP.NET Web Service Application (just accept the defaults)

    2) Select Tools > Macros > Record Temporary Macro

    3) In the Solution Explorer, right-click Service1.asmx, and select View In Browser

    4) Stop the macro recording.

    5) Select Tools > Macros > Macro Explorer

    6) In the Macro Explorer, expand MyMacros > RecordingModule

    7) Double click on 'TemporaryMacro' to run it.

     

    => Error HRESULT E_FAIL has been returned from a call to a COM component.

    This is the code generated for the macro:

    Code Snippet

    Sub TemporaryMacro()

        DTE.ActiveWindow.Object.GetItem("VSMacros\WebService1\Service1.asmx").Select(vsUISelectionType.vsUISelectionTypeSelect)

        DTE.ExecuteCommand("File.ViewinBrowser")

    End Sub

     

     

    When attempting to debug or further edit the code I have written:

    Code Snippet

    Sub TemporaryMacro()

        Dim item As UIHierarchyItem

        item = DTE.ToolWindows.SolutionExplorer.GetItem("VSMacros\WebService1\Service1.asmx")

        item.Select(vsUISelectionType.vsUISelectionTypeSelect)

        DTE.ExecuteCommand("File.ViewinBrowser")

    End Sub

     

     

    And the code fails on the DTE.ExecuteCommand("File.ViewinBrowser")

     

    Visual Studio Installed components information:

    Microsoft Visual Studio 2005
    Version 8.0.50727.762  (SP.050727-7600)
    Microsoft .NET Framework
    Version 2.0.50727 SP1

    Installed Edition: Enterprise

    Microsoft Visual Basic 2005   90613-246-0023781-41712
    Microsoft Visual Basic 2005

    Microsoft Visual C# 2005   90613-246-0023781-41712
    Microsoft Visual C# 2005

    Microsoft Visual C++ 2005   90613-246-0023781-41712
    Microsoft Visual C++ 2005

    Microsoft Visual Studio 2005 Tools for Applications   90613-246-0023781-41712
    Microsoft Visual Studio 2005 Tools for Applications

    Microsoft Visual Studio Tools for Office   90613-246-0023781-41712
    Microsoft Visual Studio Tools for the Microsoft Office System

    Microsoft Visual Web Developer 2005   90613-246-0023781-41712
    Microsoft Visual Web Developer 2005

    Microsoft Web Application Projects 2005   90613-246-0023781-41712
    Microsoft Web Application Projects 2005
    Version 8.0.50727.762

    Visual Studio 2005 Team Edition for Architects   90613-246-0023781-41712
    Microsoft Visual Studio 2005 Team Edition for Software Architects

    Visual Studio 2005 Team Edition for DB Professionals   90613-246-0023781-41712
    Microsoft Visual Studio Team Edition for Database Professionals Version 2.0.50727.251

    Visual Studio 2005 Team Edition for Developers   90613-246-0023781-41712
    Microsoft Visual Studio 2005 Team Edition for Software Developers

    Visual Studio 2005 Team Edition for Testers   90613-246-0023781-41712
    Microsoft Visual Studio 2005 Team Edition for Software Testers

    Visual Studio 2005 Team Explorer   90613-246-0023781-41712
    Microsoft Visual Studio 2005 Team Explorer
    Version 8.0.50727.762

    CodeSmith 4.0   4.0
    CodeSmith Tools Visual Studio Add-in Package

    Euricom Framework 2005   Release 1.0
    Euricom Framework 2005, Copyright 2007 Euricom N.V.

    EventToaster   1.0
    PowerToy demonstrating how to respond to IDE events from a package.

    IndexedFind   1.0
    Finds strings in files using Microsoft Indexing Service.

    Microsoft Visual C# 2005 Express Edition - ENU Service Pack 1 (KB926749)  
    This service pack is for Microsoft Visual C# 2005 Express Edition - ENU.
    If you later install a more recent service pack, this service pack will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/926749

    Microsoft Visual Studio 2005 Team Explorer - ENU Service Pack 1 (KB926601)  
    This service pack is for Microsoft Visual Studio 2005 Team Explorer - ENU.
    If you later install a more recent service pack, this service pack will be uninstalled automatically.
    For more information, visit http://support.microsoft.com/kb/926601

    Microsoft Visual Studio Team System Process Editor   1.0
    Process Editor for Microsoft Visual Studio Team Foundation Server, Version 1.0

    PowerToysMaster   1.0
    Provides the Power Toys submenu.

    SourceOutliner   1.0
    Creates a tool window that provides an outline view of a source code file.

    SQL Server Analysis Services  
    Microsoft SQL Server Analysis Services Designer
    Version 9.00.3042.00

    SQL Server Integration Services  
    Microsoft SQL Server Integration Services Designer
    Version 9.00.3042.00

    SQL Server Reporting Services  
    Microsoft SQL Server Reporting Services Designers
    Version 9.00.3042.00

    SuperDiff   1.0
    Implements the WinDiff engine in a Visual Studio tool window.

    Team Foundation Server Power Tools   1.2
    Power Tools that extend the Team Foundation Server integration with Visual Studio.

    VcCodeSnippets   1.0
    Provides basic code snippet functionality while editing C++ code.

    Visual Studio Package Load Analyzer   1.0
    A utility that analyzes package load failures in Visual Studio 2005.

    Team Foundation Sidekick 1.1
    Team Foundation Sidekicks suite, Team Foundation Sidekick 1.1. For more information about Team Foundation Sidekicks, visit Attrice Corporation website at http://www.attrice.info
    Copyright (c) 2006 Attrice Corporation

    TestDriven.NET 2.12.2179 Personal
    For more information, see the TestDriven.NET website at http://www.testdriven.net/. Development by Jamie Cansdale <jamie@mutantdesign.co.uk>.  Copyright (c) 2002-2006 Mutant Design.

    TypeMock.NET
    For more information about TypeMock, see the TypeMock website at
    http://www.TypeMock.com
    For customer support, use the forums on the site
    Copyright (c) 2005 TypeMock ltd.

     

    Monday, April 14, 2008 8:50 AM
  • I reproduced the issue under VS2005, seems like an issue with VS.

    However, under VS2008 everything is fine, and it should have been fixed in VS2008.
    Tuesday, April 15, 2008 2:59 AM
  • Unfortunately, we're in the middle of a huge project, using VS2005. And we won't be moving to VS2008 any time soon (you know company policies etc.)

     

    Is there any workaround possible or any chance of getting this fixed?

    Should I bother to make a connect issue for this?

     

     

     

    Tuesday, April 15, 2008 7:56 AM
  • I suggest that you can report this issue to the following site in the formal way:

    http://connect.microsoft.com/VisualStudio/.


    And I believe our developers can give you a better workaround.


    Thanks for your valuable feedback.

    Wednesday, April 16, 2008 2:17 AM
  • Wednesday, April 16, 2008 11:57 AM
  • This appears to still be an issue in VS2008. 

    In my case, I'm making calls as follows:

    DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()  
    DTE.ActiveWindow.Object.GetItem("A script that runs on SQL Server 2005").Select(vsUISelectionType.vsUISelectionTypeSelect)  
    DTE.ExecuteCommand("Project.Run")  
     

    The script runs fine when selecting it from the Project->Run menu, but this fails in the VS macro.  There appears to be a blocking issue since, when running from the macro, no output appears in Output Window when the first call is made.  When the call is repeated as the macro continues to run, the output from the first call appears and the second call fails with the same error as above:

    Error HRESULT E_FAIL has been returned from a call to a COM component



    Thursday, June 12, 2008 9:05 PM