【发布时间】:2012-07-13 04:16:58
【问题描述】:
我需要将一个 int 或 long 数组(没关系)从 VB6 应用程序传递给 C# COM Visible 类。我尝试过像这样在 C# 中声明接口:
void Subscribe([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_I4)]int[] notificationTypes)
void Subscribe(int[] notificationTypes)
但他们俩都提出了Function or interface markes as restricted, or the function uses an Automation type not supported in Visual Basic。
我应该如何声明 C# 方法?
【问题讨论】:
-
嗯,这很奇怪。只需删除 [MarshalAs],无需您的帮助,该数组就已经被编组为 SAFEARRAY。如果您仍然遇到问题,我们需要查看其余的接口类型。
-
@HansPassant 是的,我查看了生成的 IDL,因为它在两种情况下都正确声明为 SAFEARRAY(long),所以我认为它一定是与 VB6 相关的问题。我还在调查。
标签: c# .net vb6 interop com-interop