简体   繁体   English

如何将长数组从VB6传递到C#到COM

[英]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. 我需要将一个int或long数组(无关紧要)从VB6应用程序传递给C#COM Visible类。 I've tried declaring the interface in C# like this: 我试过像这样在C#中声明接口:

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 . 但是它们都将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? 我该如何声明C#方法?

If you get desperate, code the signature in a dummy VB6 ActiveX dll project. 如果你绝望,请在虚拟VB6 ActiveX DLL项目中编写签名。 Then generate the .NET Interop version of the vb6 component via Visual studio or the command line tool. 然后通过Visual Studio或命令行工具生成vb6组件的.NET Interop版本。 Then use Reflector or dotPeek to pull the code out of the interop assembly. 然后使用Reflector或dotPeek将代码拉出互操作程序集。 It is the long way around, but it works. 这是漫长的过程,但它的工作原理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM