Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Project Newsgroups
Project Developer
Unable to cast COM object
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Somerset Steve, post: 4893898"] This is my first use of this Microsoft Service I hope I am doing this in the right place I am suffering a very similar experience getting trying to access multiple tasks in an outlook public folder: In the past week problems have started to occur that stop the entire application from being able to save tasks. (My software is written using VB.NET in Visual Studio 2005 and I use Visual Studio Tools for the Microsoft Office (VSTO) I have narrowed the problem down to what appears (to me) to be a bug in the interop layer of the VSTO. It seems to lose track of its objects around about 160 items (140 items when not using cached mode ???!!!) I get the same results when using VSTO SE on a VISTA machine with Outlook 2007 The error is: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.TaskItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063035-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). It is definitely a taskitem Here is the code that is experiencing the problem, it works fine until the number of items returned by the Restrict statement exceeds 140-160 records. It is operating on a public folder The line that fails is the cast: task = CType(it, Outlook.TaskItem) (The code is now not quite as clean as I have tried to add checks etc. to get around the problem - none of which have worked even if I stop processing before 140 records are read - once the restrict command has executed the application has to be shut down) Private Sub RefreshData() Dim task As Outlook.TaskItem Dim objList As New Generic.List(Of Object) Dim liCount As Integer = 0 list.Clear() blList.Clear() Application.DoEvents() Dim items As Outlook.Items = gbCallActionsFolder.Folder.Items.Restrict("[" & My.Settings.TaskUpnContactId & "]='" & GetContactUserPropertyValue(ldcCustomer.Contact, My.Settings.ContactUpnId) _ & "'") ' and [CreationTime] <= '" & Format(dtpSelectUpTo.Value.AddDays(1), "D") _ ' & "' and [CreationTime] > '" & Format(dtpSelectUpTo.Value.AddDays(-6), "D") & "'") ' Dim items As Outlook.Items = gbCallActionsFolder.Folder.Items.Restrict("[" & My.Settings.TaskUpnContactId & "]='" & GetContactUserPropertyValue(ldcCustomer.Contact, My.Settings.ContactUpnId) _ ' & "' and [CreationTime] <= '" & Format(dtpSelectUpTo.Value.AddDays(1), "D") _ ' & "' and [CreationTime] > '" & Format(dtpSelectUpTo.Value.AddDays(-6), "D") & "'") MessageBox.Show("Items selected " & Str(items.Count)) Try For Each it As Object In items objList.Add(it) Next Catch ex As Exception LogError(ex, True, "Error reading messages into temp area resetting folder please try again") gbCallActionsFolder.ResetFolder() End Try Try For Each it As Object In objList task = CType(it, Outlook.TaskItem) liCount = liCount + 1 Dim ca As New CustomerCallAction(task) list.Add(ca.ReverseSearchDate & Str(list.Count), ca) If liCount > 120 Then MessageBox.Show("Number of display items exceeded, only 120 to be displayed") Exit For End If Next Catch ex As Exception LogError(ex, True, "Error reading message no:" & Str(liCount) & " resetting folder please try again") gbCallActionsFolder.ResetFolder() End Try objList = Nothing items = Nothing For Each kv As KeyValuePair(Of String, CustomerCallAction) In list blList.Add(kv.Value) Next End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Project Newsgroups
Project Developer
Unable to cast COM object
Top