N
Neil Munro
I'm having some "type" difficulty in passing a .NET array (byref) to a COM
based API (Autodesk Inventor). In VB6 the code to return an array of
tolerance values is:
Dim ToleranceCount As Long
Dim ExistingTolerances() As Double
'oSurfBody is declared and assigned in the following
Call oSurfBody.GetExistingFacetTolerances(ToleranceCount,
ExistingTolerances)
In VB.NET, the object browser shows the syntax to be:
Public Overridable Sub GetExistingFacetTolerances(ByRef ToleranceCount As
Integer, ByRef ExistingTolerances As System.Array)
Passing the array gives me a Type Mismatch error no matter how I approach
it.
Dim ToleranceCount As Integer
Dim ExistingTolerances() As Single
or
Dim ExistingTolerances() As Double
or
Dim ExistingTolerances() As Object
or
Dim ExistingTolerances As Array = Array.CreateInstance(GetType(Single),
10000)
or Double, Object versions of the above
The following fails with Type Mismatch:
Call oSurfBody.GetExistingFacetTolerances(ToleranceCount ,
ExistingTolerances)
The requirement to assign a length when using CreateInstance seems rule out
that approach, the method wants an undimensioned array.
Can anyone point out what I'm missing about passing arrays byref to com
objects.
Thanks in advance.
Neil
based API (Autodesk Inventor). In VB6 the code to return an array of
tolerance values is:
Dim ToleranceCount As Long
Dim ExistingTolerances() As Double
'oSurfBody is declared and assigned in the following
Call oSurfBody.GetExistingFacetTolerances(ToleranceCount,
ExistingTolerances)
In VB.NET, the object browser shows the syntax to be:
Public Overridable Sub GetExistingFacetTolerances(ByRef ToleranceCount As
Integer, ByRef ExistingTolerances As System.Array)
Passing the array gives me a Type Mismatch error no matter how I approach
it.
Dim ToleranceCount As Integer
Dim ExistingTolerances() As Single
or
Dim ExistingTolerances() As Double
or
Dim ExistingTolerances() As Object
or
Dim ExistingTolerances As Array = Array.CreateInstance(GetType(Single),
10000)
or Double, Object versions of the above
The following fails with Type Mismatch:
Call oSurfBody.GetExistingFacetTolerances(ToleranceCount ,
ExistingTolerances)
The requirement to assign a length when using CreateInstance seems rule out
that approach, the method wants an undimensioned array.
Can anyone point out what I'm missing about passing arrays byref to com
objects.
Thanks in advance.
Neil