By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

URGENT: COM Interop BUG!?

P: n/a
Hi,

Introduction
***************
I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system:

API Consumer ( Native C++/C# )
||
*******************************************
* Native COM Management layer *
*******************************************
||
==============
|| ||
Native COM .NET COM Interop
Object Object ( C# )

The problem:
*****************
When the 'API Consumer' uses Native C++ COM, there is no problem getting the underlying COM interface of the '.NET COM interop' object from the Management layer, BUT when the 'API Consumer' is written in C# the interface query fails with the following error: "QueryInterface for interface ISomeInterface failed.", following is the flow of the two scenarios:

1. Native C++ 'API Consumer':
***********************************
1.1. Use Native C++ to access the Management later COM ( Native )
1.2. Use the 'Native Management COM layer' to get the
interface of the '.NET COM interop' object.
1.3. The Native C++ Consumer SUCCESSFULLY uses
the interface provided by the 'Native Management COM layer'.

2. Managed C# 'API Consumer'
************************************
1.1. Use Managed C# to access the Management later COM ( Native )
1.2. Use the 'Native Management COM layer' to get the
interface of the '.NET COM interop' object results "QueryInterface
for interface ISomeInterface failed."

Following is the code flow:
1. Start the Managed C# client.
2. Create Native C++ COM management layer.
3. Create Managed C# COM interop object ( by the management layer ).
4. Ask the management layer for a certain interface of the Managed C# COM object <= Returns "QueryInterface
for interface ISomeInterface failed."

Why can't I get the interface of the managed C# COM? why does a Native C++ consumer has no problem getting the interface and a managed C# consumer does?

ThanX
Nadav.
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I'm not too sure what you're trying to do, but from what i can tell is
this...

you want a c# client to call a COM object, which is a c# .net object,
installed as a COM object via the interop?

This cannot be done, since both the client and server objects are running on
the CLR, they want to bind in .Net fashion, not switching to native code,
then back again.

..Net client can call a .Net object
..Net client can call a native (c++) COM object
native app can call a .Net object, provided it exposes the vtable, or
iDispatch pointer via interop
..Net client cannot call the .Net object via the vtable, or iDispatch pointer
(through interop) because it recognises the object as .Net, and so must be
called via .Net "referencing".

hope that helps.
Dan

"Nadav" <No*@today.com> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
Hi,

Introduction
***************
I have a system build of a collection of 'Native COM objects' and '.NET COM
interop' objects, all of the COM objects are managed through a 'Native COM'
layer, this layer manage the underlying COM Objects and upon request,
provide a pointer to those objects to the 'API Consumer', following is an
illustration of the system:

API Consumer ( Native C++/C# )
||
*******************************************
* Native COM Management layer *
*******************************************
||
==============
|| ||
Native COM .NET COM Interop
Object Object ( C# )

The problem:
*****************
When the 'API Consumer' uses Native C++ COM, there is no problem getting the
underlying COM interface of the '.NET COM interop' object from the
Management layer, BUT when the 'API Consumer' is written in C# the interface
query fails with the following error: "QueryInterface for interface
ISomeInterface failed.", following is the flow of the two scenarios:

1. Native C++ 'API Consumer':
***********************************
1.1. Use Native C++ to access the Management later COM ( Native )
1.2. Use the 'Native Management COM layer' to get the
interface of the '.NET COM interop' object.
1.3. The Native C++ Consumer SUCCESSFULLY uses
the interface provided by the 'Native Management COM layer'.

2. Managed C# 'API Consumer'
************************************
1.1. Use Managed C# to access the Management later COM ( Native )
1.2. Use the 'Native Management COM layer' to get the
interface of the '.NET COM interop' object results "QueryInterface
for interface ISomeInterface failed."

Following is the code flow:
1. Start the Managed C# client.
2. Create Native C++ COM management layer.
3. Create Managed C# COM interop object ( by the management layer ).
4. Ask the management layer for a certain interface of the Managed C# COM
object <= Returns "QueryInterface
for interface ISomeInterface failed."

Why can't I get the interface of the managed C# COM? why does a Native C++
consumer has no problem getting the interface and a managed C# consumer
does?

ThanX
Nadav.
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.