473,659 Members | 3,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InvalidComObjec tException, 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 .InteropService s.InvalidComObj ectException' 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.Release ComObject 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
threadabortexce ption , 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 1382
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.co m

"2G" <2G@pandora.b e> wrote in message
news:ev******** ******@tk2msftn gp13.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 .InteropService s.InvalidComObj ectException' 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.Release ComObject 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
threadabortexce ption , 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
1839
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 explain it in details, 1. Python initialization and finalization is done in the *main* thread. 2. For each new thread I create a separate sub-interpreter . 3. Using PyRun_String("import myModule"...) before execution of python
8
2411
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. Generally, the documentation suggests that queues or similar constructs should be used for thread inter-process comms. I've had a lot of success in doing that (generally by passing in the queue during the __init__ of the thread) and I can see...
9
2891
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(....) { // } There are multiple threads in this application that call this function. Is there any advantage if each thread creates an instance of the
9
6086
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 com+ so is there any way of making it Multi threaded TIA
3
1372
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) .... server.callLennghtyOperation(...) ....
5
5458
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 multi threaded app. My app will be need to initiate access to the database from several places in the Business logic. I'd appreaciate any advice/suggesstions on best practices to avoid problems such as accessing the same method in the data
3
4261
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 this is trying to tell me? By the way, this exception is being raised in the destructor (Finalize method) of my class when I try to close a connection. Thank you,
14
2111
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 server. I've been told time and time again that I should use an event driven server design (that is, use twisted). There is a lot of interaction between the clients and they would often need to write to the same list of values, which of course...
5
1350
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 I am finding in my debugger is that if they are backed up, I still get just one at a time. Is this just the VS 2005 integrated web server that has this behavior? -- thanks - dave
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7359
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.