- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have a VB dotnet app using a com server we are building. We need to pass in an array of types to a method. The types contain arrays of doubles.
We have succeeded in passing in one type using this code:
Dim
ar_LmdaPar(2) As Double '3 elements Dim ar_MuPar(1) As Double '2 elements Dim ar_CpPar(3) As Double '4 elements Dim mw As Doublear_LmdaPar(0) = 0.1
ar_LmdaPar(1) = 0.2
ar_LmdaPar(2) = 0.3
ar_MuPar(0) = 0.11
ar_MuPar(1) = 0.22
ar_CpPar(0) = 0.1111
ar_CpPar(1) = 0.2222
ar_CpPar(2) = 0.3333
ar_CpPar(3) = 0.4444
mw = 0.7777
Dim oneGas As AdderLib.GasKindoneGas =
New AdderLib.GasKindoneGas.GasKind(ar_LmdaPar, ar_MuPar, ar_CpPar, mw)
But when I try to create an array of the type GasKind using the code below and load it I get the error
"Object reference not set to an instance of an object"
dim
gasArray() As AdderLib.GasKindgasArray(0) =
New AdderLib.GasKind --- this line generates the errorgasArray(0).GasKind(ar_LmdaPar, ar_MuPar, ar_CpPar, mw)
The arrays all are fine as well as the double mw
I tried creating the instance then assigning it to the first element of the array like
gasArray(0) = oneGas
and still got the same error
Here is the fortran generateed by the wizard:
module
IGasKind_Methods ! These routines get implemented by the user interface function IGasKind_GasKind( ObjectData ,&LmdaPar,&
MuPar,&
CpPar,&
Mw)
result (hresult) use GasKind_Types type(GasKind_InstanceData) ObjectDataLmdaPar ,&
MuPar ,&
CpPar ,&
Mw )
result (hresult) !dec$ attributes stdcall :: $IGasKind_GasKind use GasKind_Types use ifcom implicit none type (IGasKind_Ptr) pInterface !dec$ attributes reference :: pInterface integer(INT_PTR_KIND()), intent(inout) :: LmdaPar !dec$ attributes reference :: LmdaPar integer(INT_PTR_KIND()), intent(inout) :: MuPar !dec$ attributes reference :: MuPar integer(INT_PTR_KIND()), intent(inout) :: CpPar !dec$ attributes reference :: CpPar REAL(8), intent(inout) :: Mw !dec$ attributes reference :: Mw integer(long) hresult integer i REAL(8) f$LmdaPar(1:3) pointer(ptr$LmdaPar, f$LmdaPar) integer(INT_PTR_KIND()) sa$LmdaPar!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
integer dims$LmdaPar integer lb$LmdaPar(1) integer ub$LmdaPar(1) integer nb$LmdaPar(1)!DEC$ ENDIF
REAL(8) f$MuPar(1:2) pointer(ptr$MuPar, f$MuPar) integer(INT_PTR_KIND()) sa$MuPar!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
integer dims$MuPar integer lb$MuPar(1) integer ub$MuPar(1) integer nb$MuPar(1)!DEC$ ENDIF
REAL(8) f$CpPar(1:4) pointer(ptr$CpPar, f$CpPar) integer(INT_PTR_KIND()) sa$CpPar!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
integer dims$CpPar integer lb$CpPar(1) integer ub$CpPar(1) integer nb$CpPar(1)!DEC$ ENDIF
sa$LmdaPar = NULL
!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
lb$LmdaPar = 0
ub$LmdaPar = 0
nb$LmdaPar = (/3/)
!DEC$ ENDIF
sa$MuPar = NULL
!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
lb$MuPar = 0
ub$MuPar = 0
nb$MuPar = (/2/)
!DEC$ ENDIF
sa$CpPar = NULL
!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
lb$CpPar = 0
ub$CpPar = 0
nb$CpPar = (/4/)
!DEC$ ENDIF
!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
dims$LmdaPar = SafeArrayGetDim(LmdaPar)
if (dims$LmdaPar /= 1) thenhresult = E_INVALIDARG
goto 9999 end ifhresult = SafeArrayGetLBound(LmdaPar, 1, lb$LmdaPar(1))
hresult = SafeArrayGetUBound(LmdaPar, 1, ub$LmdaPar(1))
if (nb$LmdaPar(1) /= (ub$LmdaPar(1) - lb$LmdaPar(1) + 1)) thenhresult = E_INVALIDARG
goto 9999 end if!DEC$ ENDIF
hresult = SafeArrayAccessData(LmdaPar, ptr$LmdaPar)
if (hresult < 0) goto 9999sa$LmdaPar = LmdaPar
!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
dims$MuPar = SafeArrayGetDim(MuPar)
if (dims$MuPar /= 1) thenhresult = E_INVALIDARG
goto 9999 end ifhresult = SafeArrayGetLBound(MuPar, 1, lb$MuPar(1))
hresult = SafeArrayGetUBound(MuPar, 1, ub$MuPar(1))
if (nb$MuPar(1) /= (ub$MuPar (1) - lb$MuPar(1) + 1)) thenhresult = E_INVALIDARG
goto 9999 end if!DEC$ ENDIF
hresult = SafeArrayAccessData(MuPar, ptr$MuPar)
if (hresult < 0) goto 9999sa$MuPar = MuPar
!DEC$ IF .NOT. DEFINED(NOCHECK_ARRAY_)
dims$CpPar = SafeArrayGetDim(CpPar)
if (dims$CpPar /= 1) thenhresult = E_INVALIDARG
goto 9999 end ifhresult = SafeArrayGetLBound(CpPar, 1, lb$CpPar(1))
hresult = SafeArrayGetUBound(CpPar, 1, ub$CpPar(1))
if (nb$CpPar(1) /= (ub$CpPar(1) - lb$CpPar(1) + 1)) thenhresult = E_INVALIDARG
goto 9999 end if!DEC$ ENDIF
hresult = SafeArrayAccessData(CpPar, ptr$CpPar)
if (hresult < 0) goto 9999sa$CpPar = CpPar
hresult = IGasKind_GasKind(pInterface % pInternalData % pInstanceData ,&
f$LmdaPar ,&
f$MuPar ,&
f$CpPar ,&
Mw )
if (hresult < 0) goto 9999 9999 continue ! Cleanup code if (sa$LmdaPar /= NULL) i = SafeArrayUnaccessData(sa$LmdaPar) if (sa$MuPar /= NULL) i = SafeArrayUnaccessData(sa$MuPar) if (sa$CpPar /= NULL) i = SafeArrayUnaccessData(sa$CpPar) end functionend module
I can't seem to pass in an array of these types. We have this same code working using un-managed code but really need to have a com server.
Thanks in advance!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please ignore this post or remove it. I must have been off my meds yesterday.
I was trying to have the com server create objects to be passed back to the server.
I should have been creating arrays of structures in VB and pass those to the com server instead.
Sorry to waste your time

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page