Solved

Question on marshalling C# enums for COM interop

Posted on 2009-06-29
3
830 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now