Problem when calling native dll from vb.net

M

meetviral

Hi all,
I am using Compact framework 1.1 and VS2003
I am calling following function from "C" dll declared as
TTGPS_API void WINAPI TTGPSDetailFind(HWND hTTGPS,
UINT uiNum,
UINT uiZip,
LPTSTR strOther,
LPTSTR strStreet,
LPTSTR strPlace,
LPTSTR strState,
LPTSTR strCountry,
LPTSTR strZip,
int &rltNum,
LPTSTR rltName1,
POINT &rltLoc1,
LPTSTR rltName2,
POINT &rltLoc2,
LPTSTR rltName3,
POINT &rltLoc3
);
In VC++ application this is called as below which works successfully.
g_hWndGPS=TTGPSGetWnd();
int rltNum=-1;
TCHAR rltName[3][256];
POINT rltLoc[3];
TTGPSDetailFind(g_hWndGPS,
20,
2116,
_T(""),//LPCTSTR strOther,
_T("Park Plz"),//LPCTSTR strStreet,
_T("Boston"),//LPCTSTR strPlace,
_T("MA"),//LPCTSTR strState,
_T("United States"),//LPCTSTR strCountry,
_T("02116"),//LPCTSTR strZip
rltNum,
rltName[0],
rltLoc[0],
rltName[1],
rltLoc[1],
rltName[2],
rltLoc[2]
);
In VB.NET application, dllImport declaration is as below:
<DllImport("TTGPSAPI.dll")> _
Private Shared Sub TTGPSDetailFind(ByVal ptr As IntPtr, _
ByVal StreetNum As Integer, _
ByVal Zip As Integer, _
ByVal Other As String, _
ByVal Street As String, _
ByVal Place As String, _
ByVal State As String, _
ByVal Country As String, _
ByVal Zipstr As String, _
ByRef TotalResults As Integer, _
ByVal Result1 As String, _
ByRef Result1Point As Point, _
ByVal Result2 As String, _
ByRef Result2Point As Point, _
ByVal Result3 As String, _
ByRef Result3Point As Point)
End Sub)
And in VB.NET I am calling as below:
Dim LOCAddress1 As String
Dim LOCAddress2 As String
Dim LOCAddress3 As String
'Dim LOC_Points(3) As Point

Dim LOC_Points1 As New Point(0, 0)
Dim LOC_Points2 As New Point(0, 0)
Dim LOC_Points3 As New Point(0, 0)


TTGPSDetailFind(LOC_Handle, _
20, _
2116, _
String.Empty, _
"Park Plz",_
"Boston", _
"MA", _
"United States", _
"02116", _
LOC_ResultsReturned, _
LOCAddress1, _
LOC_Points1, _
LOCAddress2, _
LOC_Points2, _
LOCAddress3, _
LOC_Points3)

When I call like this, I get following exception:

Exception Code: 0xc0000005
Exception Address: 0x01121aa4
Writing: 0x29000000

What's wrong with the above code?

Please help me.
Thanks,
Viral
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top