Satanka_Patka
New member
- Joined
- Dec 28, 2010
- Messages
- 2
- Programming Experience
- 3-5
Hi All,
I have a dll which has one function and I want to call this function from Visual Basic 2008. I tried every solution, but I couln't get it to work,
The original declaration is the following in C++
extern "C" CSSM_API void GetOptimalCSSMShaderParams(
float* outProjMatrixArray
,float* outCtrlMatrixArray
,int* outProjNumber
// LIGHT INFO:
,const float* inLightPos
,const float* inLightDir
,float inLightRange
,float inLightAngle
// CAMERA INFO:
,const float* inViewMatrix
,const float* inProjMatrix
// CSSM INFO:
,float inFocusRange
,bool columnMajorMatrices=false // Used for OpenGL
);
I defined in VB as follow
Public Declare Function GetOptimalCSSMShaderParams Lib "CSSM.dll" ByRef outProjMatrixArray() As MTV3D65.TV_3DMATRIX, ByRef outCtrlMatrixArray() As MTV3D65.TV_3DMATRIX, ByRef outProjNumber As Integer, ByVal inLightPos As MTV3D65.TV_3DVECTOR, ByVal inLightDir As MTV3D65.TV_3DVECTOR, ByVal inLightRange As Single, ByVal inLightAngle As Single, ByVal inViewMatrix As MTV3D65.TV_3DMATRIX, ByVal inProjMatrix As MTV3D65.TV_3DMATRIX, ByVal inFocusRange As Single, Optional ByVal columnMajorMatrices As Boolean = False)
I always get the following error when I wan to call the function :
System.Runtime.InteropServices.MarshalDirectiveException was unhandled
Message="PInvoke restriction: cannot return variants."
I tried to use the marshal unmanaged types, but I was no lucky.
Does anybody any idea?
Thanks
Robert
I have a dll which has one function and I want to call this function from Visual Basic 2008. I tried every solution, but I couln't get it to work,
The original declaration is the following in C++
extern "C" CSSM_API void GetOptimalCSSMShaderParams(
float* outProjMatrixArray
,float* outCtrlMatrixArray
,int* outProjNumber
// LIGHT INFO:
,const float* inLightPos
,const float* inLightDir
,float inLightRange
,float inLightAngle
// CAMERA INFO:
,const float* inViewMatrix
,const float* inProjMatrix
// CSSM INFO:
,float inFocusRange
,bool columnMajorMatrices=false // Used for OpenGL
);
I defined in VB as follow
Public Declare Function GetOptimalCSSMShaderParams Lib "CSSM.dll" ByRef outProjMatrixArray() As MTV3D65.TV_3DMATRIX, ByRef outCtrlMatrixArray() As MTV3D65.TV_3DMATRIX, ByRef outProjNumber As Integer, ByVal inLightPos As MTV3D65.TV_3DVECTOR, ByVal inLightDir As MTV3D65.TV_3DVECTOR, ByVal inLightRange As Single, ByVal inLightAngle As Single, ByVal inViewMatrix As MTV3D65.TV_3DMATRIX, ByVal inProjMatrix As MTV3D65.TV_3DMATRIX, ByVal inFocusRange As Single, Optional ByVal columnMajorMatrices As Boolean = False)
I always get the following error when I wan to call the function :
System.Runtime.InteropServices.MarshalDirectiveException was unhandled
Message="PInvoke restriction: cannot return variants."
I tried to use the marshal unmanaged types, but I was no lucky.
Does anybody any idea?
Thanks
Robert