![]() |
Specified cast is not valid
I'm developing a VSTO (second edition) addin for Outlook. One of my
customers gets the following error: "System.InvalidCastException: Specified cast is not valid. at System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal (Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.CustomMarshalers.En umerableViewOfDispatch.GetEnumerator () at System.Collections.IEnumerable.GetEnumerator() " when looping through the items in the calendar folder. Dim oFolder As MsOutlook.MAPIFolder = oSession.GetDefaultFolder (Outlook.OlDefaultFolders.olFolderCalendar) Dim oItems As MsOutlook.Items = m_oFolder.Items For Each oItem As Object In oItems .... Next Anyone who has any clue about the cause of this error? |
Specified cast is not valid
What line is the exception thrown on? Is it in the For Each line?
Does the exception get thrown if the code is changed to use a normal For loop with a loop counter? Dim count as Integer = oItems.Count Dim i As Integer For i = 1 To count ' code here Next -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Janni" wrote in message ... I'm developing a VSTO (second edition) addin for Outlook. One of my customers gets the following error: "System.InvalidCastException: Specified cast is not valid. at System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal (Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.CustomMarshalers.En umerableViewOfDispatch.GetEnumerator () at System.Collections.IEnumerable.GetEnumerator() " when looping through the items in the calendar folder. Dim oFolder As MsOutlook.MAPIFolder = oSession.GetDefaultFolder (Outlook.OlDefaultFolders.olFolderCalendar) Dim oItems As MsOutlook.Items = m_oFolder.Items For Each oItem As Object In oItems ... Next Anyone who has any clue about the cause of this error? |
All times are GMT +1. The time now is 12:28 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com