The object invoked has disconnected from its clients.

00shoe

Member
Joined
Oct 12, 2006
Messages
20
Programming Experience
3-5
Hey,

I searched this forum and could not find any post/s similar to my problem.

I have an application runinng in a remote desktop session, and it produces the following error:

Problem in StaffOff(): System.Runtime.InteropServices.COMException (0x80010108): The object invoked has disconnected from its clients. at ....

Do any one know what this means?

This error occurs in this block of code (please note that I used an Interop.Outlook Object Library) :



Private Sub sendEmail(ByVal body As String, ByVal subject As String)
' Create an Outlook application.
Dim oApp As Outlook._Application​

--Error Occurs Here
oApp = New Outlook.Application

' Create a new MailItem.
Dim oMsg As Outlook._MailItem​

oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)​
oMsg.Subject = subject​
oMsg.Body = body & vbCrLf​
oMsg.To = "emailAddress"​

' Send
oMsg.Send()​

' Clean up
oApp = Nothing
oMsg = Nothing
End Sub

Finally what is weird, is that since this program is triggered by a timer; it runs an hour later, and it will work fine (i.e. redo the program functionality and sends and email) the second time through.

Any help would be appreciated.

Thanks.
 
Last edited:
Basically what is happening is that, all threads that operate in Unmanaged areas of memory must ensure that they have completed, including the disposal of all objects, before the cycle of thread is complete.
 
Okay, I understand what you are saying. Thanks for that.

I noticed there is a .Quit() method available for Outlook.Application, so I will add that at there end, and see how that goes.
'....
' Clean up
oApp.Quit()
oApp = Nothing
oMsg = Nothing
End Sub

Thanks
 
Back
Top