![]() |
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
|
|||
|
|||
![]()
Hi All,
I am developing one VSTO COM addin for outlook 2003 in vb 2005. My code snippet is as follows. odbcrdr(0) always contains valid entryID. '------------------------------------------------------------------------------------------------------------------------------------------------------- ' Set connection & command ----- ' ---- Dim odbcrdr As OdbcDataReader odbcrdr = myCmd.ExecuteReader Dim cnt As Integer = 0 Dim c As Outlook.ContactItem Dim ns As Outlook.NameSpace ns = myGlobalApplication.GetNamespace("MAPI") While odbcrdr.Read Try c = Nothing c = ns.GetItemFromID(odbcrdr(0)) Catch ex As System.Exception AddTrace("Contact item can not be set for entryid - " & odbcrdr(0) & vbCrLf & "Exception - " & ex.Message) MsgBox("Contact item can not be set for entryid - " & odbcrdr(0) & vbCrLf & "Exception - " & ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.SystemModal) Finally c = Nothing End Try End While '------------------------------------------------------------------------------------------------------------------------------------------------------- Now when the count of returned records is greater than 250, I am always getting error on record 251 - Exception - Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063021-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). This error is always appearing on the record 251! One thing is that, all these records are on my public folder. (If those entryids are from personal folder then code is working fine!!) Please Help! Thanks, Dhananjay |
#2
|
|||
|
|||
![]()
You are running out of the 255 open messages limit impsed by Exchange.
Release the previously opened contacts using Marshal.ReleaseCOMObject. Setting the object to null won'r help since the actual call to IUnknown::Release() happens much later when the GC runs. Calling GC.Collect() every once in a while is also a good idea. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Dhananjay" wrote in message oups.com... Hi All, I am developing one VSTO COM addin for outlook 2003 in vb 2005. My code snippet is as follows. odbcrdr(0) always contains valid entryID. '------------------------------------------------------------------------------------------------------------------------------------------------------- ' Set connection & command ----- ' ---- Dim odbcrdr As OdbcDataReader odbcrdr = myCmd.ExecuteReader Dim cnt As Integer = 0 Dim c As Outlook.ContactItem Dim ns As Outlook.NameSpace ns = myGlobalApplication.GetNamespace("MAPI") While odbcrdr.Read Try c = Nothing c = ns.GetItemFromID(odbcrdr(0)) Catch ex As System.Exception AddTrace("Contact item can not be set for entryid - " & odbcrdr(0) & vbCrLf & "Exception - " & ex.Message) MsgBox("Contact item can not be set for entryid - " & odbcrdr(0) & vbCrLf & "Exception - " & ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.SystemModal) Finally c = Nothing End Try End While '------------------------------------------------------------------------------------------------------------------------------------------------------- Now when the count of returned records is greater than 250, I am always getting error on record 251 - Exception - Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063021-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). This error is always appearing on the record 251! One thing is that, all these records are on my public folder. (If those entryids are from personal folder then code is working fine!!) Please Help! Thanks, Dhananjay |
#3
|
|||
|
|||
![]()
Thank you Dmitry for your valuable suggesion.
Actually I was tried releaseCOMObject before, but it was also giving me the same error. in Finally block I wrote code like - '----------------------------------------------------- Marshal.ReleaseComObject(c) c = nothing '----------------------------------------------------- After that I wrote code like - '----------------------------------------------------- Marshal.ReleaseComObject(c) '----------------------------------------------------- i.e. not c = nothing in the finally block. etc But it is always failing on 250th record. Should I try something else? Thanks again, Dhananjay |
#4
|
|||
|
|||
![]()
Make sure you never use multipel dot notation to avoid implicit variables
created by the compiler and also call GC.Collect(). Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Dhananjay" wrote in message oups.com... Thank you Dmitry for your valuable suggesion. Actually I was tried releaseCOMObject before, but it was also giving me the same error. in Finally block I wrote code like - '----------------------------------------------------- Marshal.ReleaseComObject(c) c = nothing '----------------------------------------------------- After that I wrote code like - '----------------------------------------------------- Marshal.ReleaseComObject(c) '----------------------------------------------------- i.e. not c = nothing in the finally block. etc But it is always failing on 250th record. Should I try something else? Thanks again, Dhananjay |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to get Microsoft.Office.Interop.Outlook.TaskItem from the IUnknown (C#) | Godandag | Add-ins for Outlook | 5 | April 5th 07 09:39 AM |
Which services sends SYSTEM type messags | Mr. Smith | Outlook - General Queries | 0 | November 17th 06 12:14 PM |
Msdn help for Microsoft.Office.Interop.Outlook members | DavidE | Add-ins for Outlook | 0 | August 9th 06 07:45 AM |
Type of object for AdvancedSearch | Renjith | Outlook and VBA | 4 | May 17th 06 02:13 PM |
Move object type | Bob Smith | Outlook and VBA | 1 | May 16th 06 07:08 AM |