Re: InvalidComObjectException, threaded db access
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 05/24/04
- Next message: Micus: "use of 'new' keyword in functions"
- Previous message: Dave Bailey: "Re: String Function"
- In reply to: 2G: "InvalidComObjectException, threaded db access"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 24 May 2004 11:03:46 -0400
2G,
Abort is never a good thing. It calls TerminateThread, which I
understand can be pretty violent. I imagine that it doesn't do wonders for
COM apartments either. If possible, you should send a message to the thread
to indicate that it should stop processing.
Also, are you accessing the same instance of the database class from
multiple threads? If so, you should provide locks around the access, as I
believe most of the instance methods on classes in the System.Data namespace
are not thread safe.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"2G" <2G@pandora.be> wrote in message
news:evd8IWUQEHA.2468@tk2msftngp13.phx.gbl...
> Hi
>
> From the moment I have threaded a function that loads data from the db , I
> get the following error:
>
> An unhandled exception of type
> 'System.Runtime.InteropServices.InvalidComObjectException' occurred in
> system.data.dll
> Additional information: COM object that has been separated from its
> underlying RCW can not be used.
>
> I searched a bit on this error and saw that it could have something to do
> with Marshal.ReleaseComObject but I'm not using this.
>
> If I wait until the thread has done running and restart the thread again,
> all works fine, but this thread has to be restart the moment I click a
> button.
> Currently I 'm stopping the running thread with .Abort() and catching the
> threadabortexception , I think this has something to do with the error I'm
> getting as I suspect .Abort() is not the good way to go.
>
> Does anyone know how I could solve this?
>
> Thanks.
>
>
- Next message: Micus: "use of 'new' keyword in functions"
- Previous message: Dave Bailey: "Re: String Function"
- In reply to: 2G: "InvalidComObjectException, threaded db access"
- Messages sorted by: [ date ] [ thread ]