none
VSTO Outlook AddIn hangs for meetings in Exchange server even with Use Cache Mode On RRS feed

  • Question

  • We have developed an Outlook 2010 add-in using VSTO /C#  which exports appointments. When outlook account is in Exchange mode and Use Cache Mode OFF, we have faced the issue of Outlook hanging in our environment. If the Use Cache Mode is ON, in our environment it works properly.

    However at some customer's place we have seen that even with the Use Cache Mode is OFF, the outlook hangs due to the add-in. The code to read the meetings is as follows. It has filter and includeRecurrence set to True. It hangs specifically in the code

    foreach (Outlook.AppointmentItem apptItem in calItems )
    {...

    }

    Outlook.Items calItems = oCalendar.Items;

    calItems.Sort("[Start]", Type.Missing);

    calItems.IncludeRecurrences = true;

    calItems.Restrict(filter);

    where

    # Outlook.MAPIFolder oCalendar = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

    # filter is the query format, defined as follows,

    string filter = "[Start] <= '" + endTime.ToString("g")+ "' AND [End] >= '" + startTime.ToString("g") + "' AND [MessageClass]='IPM.Appointment'";

    My observations from the logs,

    I can see some meetings which are not in the above filter.  However  they seem to be master meetings on the recurring ones. It works properly at other customers.



    • Edited by DataK Wednesday, December 5, 2012 6:40 AM statement fix
    Wednesday, December 5, 2012 6:36 AM

Answers

  • foreach() loops create objects you cannot release. I would change the loop to declare the appointment item outside the loop and use a count-up for loop where you instantiate an instance of the appoinment using the loop index value into the calItems collection, and release the object at the end of each loop pass.
     
    My guess is that you are hitting an Exchange limit of a maximum of 255 RPC channels to the server and producing out of memory exceptions.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DataK" <=?utf-8?B?RGF0YUs=?=> wrote in message news:fd370185-7f66-4804-82e7-9fae6b146da0...

    We have developed an Outlook 2010 add-in using VSTO /C#  which exports appointments. When outlook account is in Exchange mode and Use Cache Mode OFF, we have faced the issue of Outlook hanging in our environment. If the Use Cache Mode is ON, in our environment it works properly.

    However at some customer's place we have seen that even with the Use Cache Mode is OFF, the outlook hangs due to the add-in. The code to read the meetings is as follows. It has filter and includeRecurrence set to True. It hangs specifically in the code

    foreach (Outlook.AppointmentItem apptItem in calItems )
    {...

    }

    Outlook.Items calItems = oCalendar.Items;

    calItems.Sort("[Start]", Type.Missing);

    calItems.IncludeRecurrences = true;

    calItems.Restrict(filter);

    where

    # Outlook.MAPIFolder oCalendar = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

    # filter is the query format, defined as follows,

    string filter = "[Start] <= '" + endTime.ToString("g")+ "' AND [End] >= '" + startTime.ToString("g") + "' AND [MessageClass]='IPM.Appointment'";

    My observations from the logs,

    I can see some meetings which are not in the above filter.  However  they seem to be master meetings on the recurring ones. It works properly at other customers.




    Ken Slovak MVP - Outlook
    Wednesday, December 5, 2012 2:19 PM

All replies

  • add additional logging for every line to determine exactly where it hangs. You can also CTRL + left click outlook icon in status bar and choose 'Connection status' and see column Req/Fail periodically every few seconds when it hangs to see if there is massive amount of traffic going on with exchange.
    Wednesday, December 5, 2012 7:24 AM
  • foreach() loops create objects you cannot release. I would change the loop to declare the appointment item outside the loop and use a count-up for loop where you instantiate an instance of the appoinment using the loop index value into the calItems collection, and release the object at the end of each loop pass.
     
    My guess is that you are hitting an Exchange limit of a maximum of 255 RPC channels to the server and producing out of memory exceptions.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DataK" <=?utf-8?B?RGF0YUs=?=> wrote in message news:fd370185-7f66-4804-82e7-9fae6b146da0...

    We have developed an Outlook 2010 add-in using VSTO /C#  which exports appointments. When outlook account is in Exchange mode and Use Cache Mode OFF, we have faced the issue of Outlook hanging in our environment. If the Use Cache Mode is ON, in our environment it works properly.

    However at some customer's place we have seen that even with the Use Cache Mode is OFF, the outlook hangs due to the add-in. The code to read the meetings is as follows. It has filter and includeRecurrence set to True. It hangs specifically in the code

    foreach (Outlook.AppointmentItem apptItem in calItems )
    {...

    }

    Outlook.Items calItems = oCalendar.Items;

    calItems.Sort("[Start]", Type.Missing);

    calItems.IncludeRecurrences = true;

    calItems.Restrict(filter);

    where

    # Outlook.MAPIFolder oCalendar = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

    # filter is the query format, defined as follows,

    string filter = "[Start] <= '" + endTime.ToString("g")+ "' AND [End] >= '" + startTime.ToString("g") + "' AND [MessageClass]='IPM.Appointment'";

    My observations from the logs,

    I can see some meetings which are not in the above filter.  However  they seem to be master meetings on the recurring ones. It works properly at other customers.




    Ken Slovak MVP - Outlook
    Wednesday, December 5, 2012 2:19 PM
  • Thanks Ken. I'll try to modify the code as per your suggestions and post back.
    Friday, December 7, 2012 6:30 AM