We have a legacy C++ COM DLL that defines a struct in the IDL.
Simplified version of the IDL contains:
typedef struct
{
int num;
} LegacyStruct;
interface ILegacyInterface : IUnknown
{
HRESULT GetStruct( [in,out] LegacyStruct* pVal );
}
We now need to define a .Net C# COM-visible assembly that implements ILegacyInterface.
In a C# project we add a reference to the legacy COM DLL and define a class that implements this interface:
[ComVisible( true )]
public class CSClass : ILegacyInterface
{
public void GetStruct( ref LegacyStruct pVal )
{
....
}
}
The goal is to then utilize this COM-exposed C# assembly class in a C++ COM client program. This program should be able to use both the legacy COM DLL and the new C# assembly classes that implement ILegacyInterface.
When compiling, the following warning is displayed:
Type library exporter warning processing 'CSClass.GetStruct(pVal)'. warning : Non COM visible value type 'LegacyStruct' is being referenced either from the type currently being exported or from one of its base types.
As a result of LegacyStruct being non-COM visible, the resulting assembly's .tlb does not have GetStruct() method exposed (i.e., when viewed using oleview).
Obviously the C++ COM client does not compile:
error C2039: 'GetStruct' : is not a member of 'CSClass'
Is there a way to ensure that LegacyStruct, which is defined in the legacy C++ COM DLL, is properly exposed when utilized in a C# COM-visible .Net assembly's methods?