473,409 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

InvalidComObjectException, threaded db access

2G
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.InvalidComObjectEx ception' 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.
Nov 16 '05 #1
1 1375
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]
- mv*@spam.guard.caspershouse.com

"2G" <2G@pandora.be> wrote in message
news:ev**************@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.InvalidComObjectEx ception' 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.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
8
by: Matthew Bell | last post by:
Hi, I've got a question about whether there are any issues with directly calling attributes and/or methods of a threaded class instance. I wonder if someone could give me some advice on this. ...
9
by: Seenu | last post by:
Is it safe to create a static function in a multi threaded application ? As an example, I have a function that logs errors ,exceptions and some informational data public static void Log(....) {...
9
by: Stu | last post by:
Hi, I have a web service that does database access and calculations However it keeps falling over becuase its not multi threaded and each call to it is not in its own space!! I dont want to use...
3
by: | last post by:
Hi to everybody, I have the following situation: I have a lengthy operation inside a desktop application - something that has to be executed on the main thread of the app (this is a must) .......
5
by: Macca | last post by:
Hi, I have a multithreaded app which now needs database storage. I am in the process of designing my Data Access Layer but and was wondering what issues I should look for for in regards to a...
3
by: Jason Richmeier | last post by:
I have received an InvalidComObjectException in my code with the message "COM object that has been separated from its underlying RCW cannot be used". Can anyone explain (in simple terms) what...
14
by: Snor | last post by:
I'm attempting to create a lobby & game server for a multiplayer game, and have hit a problem early on with the server design. I am stuck between using a threaded server, and using an event driven...
5
by: David Thielen | last post by:
I assumed that requests to my app are multi-threaded in that is there are 2 browsers making requests at the same time, I could be in the middle of responding to one when I get the next. But what...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.