0

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.