G
Guest
I am trying to wrap an unmanaged DLL. The function I am currently trying to
wrap is defined as this:
KPDCStatus KPDCAllocCameraIterator( KPDCLibMgrRef inManagerRef,
KPDCCameraIterRef *outRef);
The types they are defined this way:
typedef void* KPDCOpaqueRef;
typedef KPDCOpaqueRef KPDCLibMgrRef;
typedef KPDCIteratorRef KPDCCameraIterRef;
So, basically the function takes 2 IntPtrs, one of the ByReference. So I
wrote my VB code like this:
Declare Auto Function KAllocCamera Lib "DCSPro4SLR.dll" Alias
"KPDCAllocCameraIterator" (ByVal inManagerRef As IntPtr, ByRef outRef As
IntPtr)
Private Sub FireItUp()
Dim myLibMgr As IntPtr = Marshal.AllocHGlobal(1)
Dim myCamIter As IntPtr = Marshal.AllocHGlobal(1)
....
'Some code that gets passed myLibMgr and fills it
....
myStatus = myPro4.KAllocCamera(myLibMgr, myCamIter)
End Sub
But I get this error:
System.Runtime.InteropServices.MarshalDirectiveException: PInvoke
restriction: can not return variants.
What's it all mean? The MarshalDirectiveException?
wrap is defined as this:
KPDCStatus KPDCAllocCameraIterator( KPDCLibMgrRef inManagerRef,
KPDCCameraIterRef *outRef);
The types they are defined this way:
typedef void* KPDCOpaqueRef;
typedef KPDCOpaqueRef KPDCLibMgrRef;
typedef KPDCIteratorRef KPDCCameraIterRef;
So, basically the function takes 2 IntPtrs, one of the ByReference. So I
wrote my VB code like this:
Declare Auto Function KAllocCamera Lib "DCSPro4SLR.dll" Alias
"KPDCAllocCameraIterator" (ByVal inManagerRef As IntPtr, ByRef outRef As
IntPtr)
Private Sub FireItUp()
Dim myLibMgr As IntPtr = Marshal.AllocHGlobal(1)
Dim myCamIter As IntPtr = Marshal.AllocHGlobal(1)
....
'Some code that gets passed myLibMgr and fills it
....
myStatus = myPro4.KAllocCamera(myLibMgr, myCamIter)
End Sub
But I get this error:
System.Runtime.InteropServices.MarshalDirectiveException: PInvoke
restriction: can not return variants.
What's it all mean? The MarshalDirectiveException?