jonathanpeppers
jonathanpeppers

Reputation: 26495

C# COM Server - Testing in C++

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?

Upvotes: 0

Views: 146

Answers (1)

Hans Passant
Hans Passant

Reputation: 941357

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.

Upvotes: 2

Related Questions