Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Question on marshalling C# enums for COM interop

Posted on 2009-06-29
3
Medium Priority
?
891 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
abel earned 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

664 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