T
Terry
Hi,
I am using VS2005 and am having a problem accessing a function in a .Net
assembly exposed to Com that uses a ParamArray.
Here is a contrived example...
Public Interface IAdder
Function Adder(ByVal ParamArray Ints() As Integer) As Integer
End Interface
<ComClass(Foo.ClassId, Foo.InterfaceId, Foo.EventsId)> _
Public Class Foo
Implements IAdder
#Region "COM GUIDs"
Public Sub New()
MyBase.New()
End Sub
Public Function Adder(ByVal ParamArray Ints() As Integer) As Integer
Implements IAdder.Adder
Dim temp As Integer = 0
For Each i As Integer In Ints
temp += i
Next
Return temp
End Function
End Class
And the VB6 code ...
Dim c As New ComClass.Foo
Dim a As Integer
a = c.Adder(1, 2, 3, 4) <=== gets the following runtime error:
Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic
I did a google search and came up with the following KB article (which seems
to only relate to VS 2002 and 2003...
http://support.microsoft.com/kb/327084
The article says the work around is to pass the ParamArray ByRef, but VS2005
says a ParamArray can NOT be passed ByRef!
So, what do I do?
TIA,
I am using VS2005 and am having a problem accessing a function in a .Net
assembly exposed to Com that uses a ParamArray.
Here is a contrived example...
Public Interface IAdder
Function Adder(ByVal ParamArray Ints() As Integer) As Integer
End Interface
<ComClass(Foo.ClassId, Foo.InterfaceId, Foo.EventsId)> _
Public Class Foo
Implements IAdder
#Region "COM GUIDs"
Public Sub New()
MyBase.New()
End Sub
Public Function Adder(ByVal ParamArray Ints() As Integer) As Integer
Implements IAdder.Adder
Dim temp As Integer = 0
For Each i As Integer In Ints
temp += i
Next
Return temp
End Function
End Class
And the VB6 code ...
Dim c As New ComClass.Foo
Dim a As Integer
a = c.Adder(1, 2, 3, 4) <=== gets the following runtime error:
Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic
I did a google search and came up with the following KB article (which seems
to only relate to VS 2002 and 2003...
http://support.microsoft.com/kb/327084
The article says the work around is to pass the ParamArray ByRef, but VS2005
says a ParamArray can NOT be passed ByRef!
So, what do I do?
TIA,