473,503 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InvalidComObjectException Explanation...

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,

Jason Richmeier
Apr 27 '06 #1
3 4253
Hi

From your description you are trying to call a COM object from .NET. The
calling route is as below.
..NET--->RCW--->COM.

From the error, it seems that you are trying to calling the method of
closeconnection, but at that time the RCW have release all the COM
reference to the COM. So the .NET can not access the COM via RCW which
cause the problem.

I suggest you try to call the closeconnection at a earlier time.
Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 28 '06 #2
I think that makes sense (sort of).

If I put the code to close the connection in the Dispose method (which is
called before the object goes out of scope) everything works fine. My
interpretation is that the destructor will not get called until the object is
garbage collected (which occurs long after the object goes out of scope from
my observation). Is this kind of what you are talking about?

By the way, I hope this doesn't sound like to silly of a question but what
is the RCW and what is its purpose in life (I am assuming it is some sort of
a bridge between .NET and COM).

Thank you,

Jason Richmeier

""Peter Huang" [MSFT]" wrote:
Hi

From your description you are trying to call a COM object from .NET. The
calling route is as below.
.NET--->RCW--->COM.

From the error, it seems that you are trying to calling the method of
closeconnection, but at that time the RCW have release all the COM
reference to the COM. So the .NET can not access the COM via RCW which
cause the problem.

I suggest you try to call the closeconnection at a earlier time.
Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 28 '06 #3
Hi

Yes, the destructor will be called by GC in C#, which is the finalize
method.

As your understanding, the RCW is bridge between .NET and unmanaged world.
Because .NET can not call the unmanaged COM directly.
The whole name of RCW is runtime called wrapper.
Runtime Callable Wrapper
http://msdn2.microsoft.com/en-us/library/8bwh56xe.aspx

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

May 1 '06 #4

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

Similar topics

3
2504
by: David MacQuigg | last post by:
I am writing a chapter for teaching OOP in Python. This chapter is intended as a brief introduction to replace the more complete discussion in Learning Python, 2nd ed, pp. 295-390. I need to...
2
507
by: MatthewRoberts | last post by:
Howdy All, I have a Windows Service that often stops in its tracks with no exception and no explanation on our QA system. During testing on the development machine, it can handle any workload,...
1
3321
by: jimfortune | last post by:
From: http://groups-beta.google.com/group/comp.databases.ms-access/msg/769e67e3d0f97a90?hl=en& Errata: 19 solar years = 2939.6018 days should be 19 solar years = 6939.6018 days Easter...
1
1376
by: 2G | last post by:
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...
2
2413
by: Dave Taylor | last post by:
Is there a decent explanation of how menu merging with MDI forms work in VB.NET? I've read through the online help and it still seems that whenever I change menus around or whatever, it breaks...
12
2087
by: jacob navia | last post by:
Hi I am writing this tutorial stuff again in the holidays and I came across this problem: The "width" field in printf is a minimum width. Printf will not truncate a field. for instance:...
4
1527
by: dismantle | last post by:
Hi all, this is my 3rd week in studying VB codes and i came across with this codes from a online tutorial about classes. Public Function MiddleInitial() As String MiddleInitial =...
6
2459
by: WolfgangS | last post by:
Ok first off, i am a total beginner at this groups stuff and i have no clue how this works. This is probabaly the wrong group for my problem but i will post it anyways. Learning by doing right? ...
16
1636
by: DamienS | last post by:
In the interests of me saving hair, can someone please explain to me what's going on below? Why doesn't == work in comparing two int's when cast as objects? They're the same type. Note that it...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
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
7339
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...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5581
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
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
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...

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.