Solved

Question on marshalling C# enums for COM interop

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

910 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

19 Experts available now in Live!

Get 1:1 Help Now