Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass a long array from VB6 to C# thru COM

I need to pass an array of int or long (doesn't matter) from a VB6 application to a C# COM Visible class. I've tried declaring the interface in C# like this:

void Subscribe([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_I4)]int[] notificationTypes)

void Subscribe(int[] notificationTypes)

But both of them raised a Function or interface markes as restricted, or the function uses an Automation type not supported in Visual Basic.

How should I declare the C# method?

like image 623
Ignacio Soler Garcia Avatar asked Nov 14 '22 02:11

Ignacio Soler Garcia


1 Answers

If you get desperate, code the signature in a dummy VB6 ActiveX dll project. Then generate the .NET Interop version of the vb6 component via Visual studio or the command line tool. Then use Reflector or dotPeek to pull the code out of the interop assembly. It is the long way around, but it works.

like image 89
tcarvin Avatar answered Dec 21 '22 21:12

tcarvin