Link to home
Start Free TrialLog in
Avatar of soulaco
soulaco

asked on

Question on marshalling C# enums for COM interop

I have a function in C# that takes in an array of an enum. For some reason I can't seem to get this to make itself visible to COM properly. In the VB6 object browser the function parameter reads <Unsupported Variant Type>.

Here is my function from my public interface:
void CurveListRequest (string RequestID, CurveNameConstants[] Curves);

The parameter 'CurveNameConstants[]' is an enum. Is there any way to make this work so someone using VB6 or VBA could enter the enums into the function?

I have tried several of the MarshalAs attribute types but none of them seem to solve the issue.
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of soulaco
soulaco

ASKER

The solution there doesn't seem to work for me. My enum is public and the function is defined as follows:

void CurveListRequest (string RequestID, ref CurveNameConstants[] Curves)
This is how the function looks in the typelib:

HRESULT CurveQuoteRequest( [in] BSTR RequestID,  [in, out] SAFEARRAY(unsigned int)* Curves);

It doesn't show the parameter as being of the enum type.

When I try to use the function, it gives me an error.

How do you marshall an array of enums for use in COM?
you graded low, that means that you were perhaps not completely satisfied with the answer, but you graded and closed the question. Don't expect experts to come back at a question if you close it and don't expect them to come back at all when you clearly show that you don't like the answer and don't want to pursue it further.

On closing: https://www.experts-exchange.com/help.jsp?hi=407 and https://www.experts-exchange.com/help.jsp?hi=403.

On reopening: https://www.experts-exchange.com/help.jsp?hi=404