Solved

Question on marshalling C# enums for COM interop

Posted on 2009-06-29
3
859 Views
Last Modified: 2013-11-10
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.
0
Comment
Question by:soulaco
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24740921
It seems that VB can only do in/out arrays. Check the following post with a similar problem, below the page is the solution: http://www.eggheadcafe.com/forumarchives/NETFrameworkinterop/Oct2005/post24405866.asp
0
 

Author Comment

by:soulaco
ID: 24744941
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?
0
 
LVL 39

Expert Comment

by:abel
ID: 24745386
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: http://www.experts-exchange.com/help.jsp?hi=407 and http://www.experts-exchange.com/help.jsp?hi=403.

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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question