开发者

ParamArray Not Working With COM

开发者 https://www.devze.com 2023-01-09 00:56 出处:网络
I have a Class Library that is exposed to COM 开发者_如何转开发like this: <ComClass(SomeClass.ClassId, SomeClass.InterfaceId, SomeClass.EventsId)>

I have a Class Library that is exposed to COM 开发者_如何转开发like this:

<ComClass(SomeClass.ClassId, SomeClass.InterfaceId, SomeClass.EventsId)>
Public Class SomeClass

    Public Const ClassId As String = "GUID1"
    Public Const InterfaceId As String = "GUID2"
    Public Const EventsId As String = "GUID3"

    Public Sub SomeMethod(ByVal ParamArray values() As Object)
        ''//Some Code Here    
    End Sub
End Class

I then used regasm /tlb /codebase to to register it. All methods and properties seem to work correctly in VBA/VB6 but when I try to access the Method with a ParamArray it won't event compile. I get the error:

Compile error:

Function or interface marked as restricted, or the function uses an Automation type not suppport in Visual Basic.

What do I need to do to properly expose this Method so I can use it like this?:

SomeClass.SomeMethod 1, 2, 3


the function uses an Automation type not supported in Visual Basic.

The buck stops there, there is no equivalent of parameter arrays in VB6. Drop the ParamArray keyword. The VB6 code has to pass an array of Variants. Unpleasant, consider redesigning your class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号