![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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? |
#2
|
|||
|
|||
![]()
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? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass' | John Yovas | Add-ins for Outlook | 2 | September 12th 08 04:23 PM |
'not a valid win 32 application' | les60leeds | Outlook - Using Contacts | 1 | October 31st 07 01:51 PM |
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. | Dhananjay | Outlook and VBA | 3 | October 13th 07 07:56 AM |
contacts.pst not valid | binnsdrafting | Outlook - Using Contacts | 2 | August 13th 06 04:32 AM |
Parameters not valid | Suedra | Outlook - Calandaring | 0 | February 24th 06 12:57 AM |