I have a legacy MFC application that I wish to have interact with a C# library.
In C# I have something like:
namespace MyManagedLibrary { [ComVisible(true)] [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct MyStruct { public int data1; public bool someFlag; public double syringeSize; } [ComVisible(true)] public class MyClass { public void Set(MyStruct structures, string path) { } } }
I build MyManagedLibrary and create a type library that can be imported in to the legacy unmanaged application, the MyClass.Set(...) function becomes something like:
void Set(SAFEARRAY * structures, LPCTSTR path) { static BYTE parms[] = VTS_UNKNOWN VTS_BSTR ; InvokeHelper(0x60020004, DISPATCH_METHOD, VT_EMPTY, NULL, parms, structures, path); }
From the tlh file I can get a definition of MyStruct but when if I try from managed code:
CComSafeArray<MyStruct> saConfigurations(structureCount);
I get: error C2039: 'type' : is not a member of 'ATL::_ATL_AutomationType<T> - amongst other errors, so how do I create a CComSafeArray of MyStruct structures?
Thank you.