J
John Alway
Hello,
I'm using a DLL I wrote in C++, and am attempting to call and use it
from VB.
This works fine for functions where I pass parameters by value, but I
can't get pointers to work.
I get the following error in the VB.net application:
"An unhandled exception of Type
'System.Runtime.InteropServices.MarshalDirectiveException' occurred in
Pendant.exe "PInvoke restriction: can not return variants""
For the dll, GamePad.dll, I have functions set up thus:
#define DllExport extern "C" __declspec(dllimport) __stdcall
void DllExport TestFunction(int *pv)
{
*pv = 987; // just pass back any arbitrary value
}
In Visual Basic I have the function imported thus:
<DllImport("gamepad.dll")> Public Shared Function TestFunction(ByRef v
As Integer)
End Function
Then, I use the function in a button:
Dim result As Integer
TestFunction(result)
TextBox1.Text = result.ToString
The error occurs right at the TestFunction() call.
Does anyone have any ideas?
Thanks for any feedback.
Regards,
....John
I'm using a DLL I wrote in C++, and am attempting to call and use it
from VB.
This works fine for functions where I pass parameters by value, but I
can't get pointers to work.
I get the following error in the VB.net application:
"An unhandled exception of Type
'System.Runtime.InteropServices.MarshalDirectiveException' occurred in
Pendant.exe "PInvoke restriction: can not return variants""
For the dll, GamePad.dll, I have functions set up thus:
#define DllExport extern "C" __declspec(dllimport) __stdcall
void DllExport TestFunction(int *pv)
{
*pv = 987; // just pass back any arbitrary value
}
In Visual Basic I have the function imported thus:
<DllImport("gamepad.dll")> Public Shared Function TestFunction(ByRef v
As Integer)
End Function
Then, I use the function in a button:
Dim result As Integer
TestFunction(result)
TextBox1.Text = result.ToString
The error occurs right at the TestFunction() call.
Does anyone have any ideas?
Thanks for any feedback.
Regards,
....John