Visual Studio Developer Center > Visual Studio Forums > Visual Studio Debugger > Cannot see object details in debugger (System.__ComObject)
Ask a questionAsk a question
 

AnswerCannot see object details in debugger (System.__ComObject)

  • Thursday, November 05, 2009 8:48 PMcardel_cz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi,
    I have problem with debugging in Visual Studio Express 2008. I tried to run downloaded example from msdn, which works with Outlook. I would like to work with Outlook folders etc..

    Example in VB:
    Imports Outlook = Microsoft.Office.Interop.Outlook
    Imports Microsoft.Office.Interop.Outlook.OlUserPropertyType
    
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim olApp As Outlook.Application
            Dim objNS As Outlook.NameSpace
            Dim bcmRootFolder As Outlook.Folder
            Dim olFolders As Outlook.Folders
            Dim bcmAccountsFldr As Outlook.Folder
            Dim bcmProjectsFolder As Outlook.Folder
            Dim bcmProjectTasksFolder As Outlook.Folder
            Dim existAcct As Outlook.ContactItem
            Dim newProject As Outlook.TaskItem
            Dim newProjectTask As Outlook.TaskItem
            Dim userProp As Outlook.UserProperty
            Dim myAccount As Outlook.ContactItem
    
    
            olApp = CreateObject("Outlook.Application")
            objNS = olApp.GetNamespace("MAPI")
            olFolders = objNS.Session.Folders
    
            bcmRootFolder = olFolders("Business Contact Manager")
            bcmAccountsFldr = bcmRootFolder.Folders(1)
    
    
    whole example is here:
    http://msdn.microsoft.com/en-us/library/bb267920.aspx


    Program works fine, but I am not able to debug all objects, that I am using. When I try to look to "bcmRootFolder" or "bcmAccountsFldr" in debugger I will get {System.__ComObject} with no detailed informations.

    Screenshot with watch expressions is here:

    http://img694.imageshack.us/img694/3589/vbdebug.jpg

    When I tried run the same code as Macro in Outlook I've got the Outlook.Folder object for "bcmRootFolder" or "bcmAccountsFldr" ... with detailed informations in VB debugger in Outlook.

    I tried run the same example in C# Express 2008, VB Express 2008 but with same results. {System.__ComObject} with no detailed informations

    I have Outlook 12.0 Object Library in project references.

    Can You tell me what I am doing wrong? How can I see detailed informations and objects with exacts types in VB Express or C# Express debugger?

    Thank You

Answers

All Replies

  • Friday, November 06, 2009 5:12 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello cardel,

    Thanks for your posts. You are absolutely right. It seems that the Watch window could not evaluate our expressions. To narrow down the issue, please go to Immediate window and type "olFolders.GetFirst()" to see if it gives the detailed information of the folders.

    Also, please go to the directory of Visual Studio and find the Debugger Visualizer folder, it is usually located under:
    <Drive>:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers, could you please list the file name there?

    The System._ComObject class is a wrapper for COM Objects in CLR, to get the type name of the object, we could use *as* operator to cast the type (please to this KB article for more information), OR, we could use the Immediate window, type "Microsoft.VisualBasic.Information.TypeName(olFolders)" will return the type name of the olFolders object.

    Please have a try and tell me the result.
    Best regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
  • Saturday, November 07, 2009 2:36 PMcardel_cz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    1) I typed "bcmRootFolder = olFolders.GetFirst() " into Immediate window and bcmRootFolder was of type {System.__ComObject}

    2) I have these files on my disc

    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers\

    Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll (53 248 B)


    C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers\Original
    autoexp.cs (10 021 B)
    autoexp.dll (37 888 B)
    autoexpce.cs (8 280 B)
    autoexpce.dll (22 016 B)


    3) I tried example with "AS " operator in C# , but I have the same result. I know the type of my object, and if I condition "(bcmRootFolder as Outlook.Folder) != null " was succesfull.

    Result is on THIS picture

    4) I tried print result of TypeName function

    Debug.Print(Microsoft.VisualBasic.Information.TypeName(olFolders))
    FoldersClass

    Debug.Print(Microsoft.VisualBasic.Information.TypeName(bcmRootFolder))
    MAPIFolder


    5) I tried cast in VB

    Dim bcmCast As Outlook.Folder
    bcmCast = CType(bcmRootFolder, Outlook.Folder)


    but bcmCast variable had still type {System.__ComObject}

    Only way to succesfully debug my application is to write it as macro in Visual Basic Editor of  Outlook, Word, Excel... There I can se all details of objects, Outlook folders etc..

    I hope, there will be some better solution




  • Monday, November 09, 2009 4:41 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    Thanks for your feedback. Since there are richful debugging features with Team/Professional edition of Visual Studio, I encourage you to evaluate it in a higher edition of VS. I currently did not have a Expression version. I guess the detailed information is not shown in Express edtion, I'll prove that as soon as possible.

    Best regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
  • Monday, November 09, 2009 4:44 PMcardel_cz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Detailed information is not shown in Express edtion but shown in VB editor in Word, Excel ... ? It is curious...
    I don´t think that higher version fix it... But I will try it
  • Wednesday, November 11, 2009 12:11 PMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello cardel,

    Just for your information, there is a dynamic view in Visual Studio 2010 which shows the detailed information of the System._ComObject type:
    http://msdn.microsoft.com/en-us/library/dd998308(VS.100).aspx

    Thanks
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
  • Thursday, November 12, 2009 6:43 PMrchiodo - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Roahn is right. In VS 2008 and earlier there is no way to see the data members of a System._COMObject. VS 2010 provides more support for this as long as it can find the assemblies that the COM object implements.

    See Habib's blog entry about it here:
    http://blogs.msdn.com/habibh/archive/2009/09/22/debugging-a-com-object-runtime-callable-wrapper-with-visual-studio-2010.aspx