开发者

C# COM Server - Testing in C++

开发者 https://www.devze.com 2022-12-13 19:41 出处:网络
I have some C# interfaces exposed to COM: interface IMyInterface { IMyListObject[] MyList { get; } } interface IMyListObject

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消