URGENT: COM Interop BUG!?

N

Nadav

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.
 
D

Daniel Bass

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top