Results 1 to 3 of 3

Thread: The object invoked has disconnected from its clients.

  1. #1
    00shoe's Avatar
    00shoe is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Oct 2006
    Posts
    20
    Reputation
    83

    Question The object invoked has disconnected from its clients.

    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 by 00shoe; 10-22-2006 at 10:23 PM.

  2. #2
    vis781's Avatar
    vis781 is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2005
    Location
    Cambridge, UK
    Posts
    2,015
    Reputation
    250
    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.
    GDI+ Code Generation Utility : GDI+ Architect

    A Must : FxCop .Net Code analyzer : FxCop

  3. #3
    00shoe's Avatar
    00shoe is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Oct 2006
    Posts
    20
    Reputation
    83
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking