That error is a startup load error for a COM addin. The only way to tell
what's failing in the load is to do managed code troubleshooting and look at
the Fusion logs. See
http://blogs.msdn.com/vsod/archive/2...-failures.aspx
for information on that.
Usually if you run out of RPC channels it's against Exchange server, and it
usually happens at around 250 passes in a loop. That's due to managed code
not releasing objects in the garbage collector soon enough, your pause may
help by allowing the GC to run. A better approach is to explicitly release
all of your objects by setting them to Nothing, and you may even have to
call Marshal.ReleaseComObject() on them and then call to GC.Collect() each
pass in the loop.
Also, never use compound dot operators such as this:
sClassComp = oItemsm.Item(i).messageclass
That creates an internal object for the oItemsm.Item(i) object that can't be
explicitly released. Use instead something like this:
Dim item As object = oItemsm.Item(i)
sClassComp = item.MessageClass
That allows you to explicitly release "item".
However, the error when you run into a limit on RPC channels is usually a
lack of resources or memory error, not a load error.
Another thing is if this code is running in an Outlook COM addin never, ever
use New to create an Outlook.Application object. Instead, use the
Application object passed to you in Startup() for VSTO addins or in
OnConnection() in shared addins.
--
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
"DP" wrote in message
...
Receiving message in Outlook when call interop from vb.net and trying to
read/load emails from inbox to windows form into datagridview.
Message is: The add-in "c\program files\postx\trusted messaging client
for
outlook\..." could not be installed or loaded.
This message occurs at different times, never on the same email. Usually
after it loads over 150 emails. We think it is related to COM
performance,
thus put in System.Threading.Thread.Sleep(100), this seems to work, but
slow
to load emails.
Any input would be helpful. Here is the basic code.
Dim oAppm As Microsoft.Office.Interop.Outlook.Application = New
Microsoft.Office.Interop.Outlook.Application
Dim oInboxm As Microsoft.Office.Interop.Outlook.MAPIFolder
Dim oItemsm As Microsoft.Office.Interop.Outlook.Items
Dim oNSm As Microsoft.Office.Interop.Outlook.NameSpace =
oAppm.GetNamespace("MAPI")
oInboxm =
oNSm.GetDefaultFolder(Microsoft.Office.Interop.Out look.OlDefaultFolders.olFolderInbox)
oItemsm = oInboxm.Items
For i As Integer = oItemsm.Count To 1 Step -1
'Test to make sure item is a mail item and not a meeting request.
sClassComp = oItemsm.Item(i).messageclass
Select Case sClassComp
Case "IPM.Note",
"IPM.Note.Rules.ReplyTemplate.Microsoft", "IPM.Note.Secure"
Me.DataGridView1.Rows.Add()
Dim oMsgm As Microsoft.Office.Interop.Outlook.MailItem
oMsgm = TryCast(oItemsm.Item(i),
Microsoft.Office.Interop.Outlook.MailItem)
iCellCounter = 0
Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter).Value =
oMsgm.SenderName
Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 1).Value =
oMsgm.Subject
Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 2).Value =
oMsgm.ReceivedTime
Me.DataGridView1.Rows(iRowCounter).Cells(iCellCoun ter + 3).Value =
oMsgm.ConversationIndex
Pause()
iRowCounter += 1
Case Else
End Select
Next i