tags:

views:

50

answers:

1

I have some C# interfaces exposed to COM:

interface IMyInterface
{
  IMyListObject[] MyList
  {
    get;
  }  
}

interface IMyListObject
{
//properties that don't matter
}

So far I'm testing how our assembly is exposed to COM from C++ and most is working just fine.

My current problem is at one point I have 2 instances of IMyInterface and need to copy from one MyList to another.

If I just call this in C++:

myInterfaceB->MyList = myInterfaceA->MyList;

This gives the HRESULT of E_POINTER.

MyList returns a SAFEARRAY*, the equivalent code works just fine in C#.

I'm not generally a C++ developer, how do I fix this?

+2  A: 

Not sure if E_POINTER makes sense or why it would work in C#. It can't work, your MyList property doesn't have a property setter. It doesn't really need one, you don't have to change the array, only the array contents. Use the SafeArrayXxxx() functions, using the ATL CComSafeArray or MFC COleSafeArray wrappers makes it easier.

Hans Passant
The problem was I was exposing the array as the class instead of the interface that was exposed to com. Have some free points for answering.
Jonathan.Peppers