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

Ign*_*cia 5 .net c# vb6 interop com-interop

我需要将一个 int 或 long 数组(无关紧要)从 VB6 应用程序传递到 C# COM Visible 类。我试过像这样在 C# 中声明接口:

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

void Subscribe(int[] notificationTypes)
Run Code Online (Sandbox Code Playgroud)

但他们俩都举了一个Function or interface markes as restricted, or the function uses an Automation type not supported in Visual Basic

我应该如何声明 C# 方法?

tca*_*vin 1

如果您感到绝望,请在虚拟 VB6 ActiveX dll 项目中编写签名。然后通过 Visual Studio 或命令行工具生成 .NET Interop 版本的 vb6 组件。然后使用 Reflector 或 dotPeek 将代码从互操作程序集中拉出。虽然路途遥远,但很有效。