ERROR: Object Reference Not Set to an Instance of an Object

M

Michael Chong

I have an (exe) executable program created in VB.NET 2003 that calls to a
MFC DLL written in VC++.NET 2003. I always get an error msg
"NullReferenceException: Object Reference Not Set to an Instance of an
Object" when my exe calls the following codes:

in VB.NET

Declare Function test Lib "C:\Cyob\IOComm\Debug\IOComm.dll" _
(ByVal a As Long, ByRef b As Integer) As Integer

Dim did As Integer
Dim ret As Integer

ret = test(PortHnd, did) //ERROR: Object Reference Not Set to an
Instance of an Object


in VC++.NET

extern "C" int APIENTRY test(HANDLE a, int *b)
{
*b=55; //ERROR: Object Reference Not Set to an Instance of an
Object
return 99;
}


Why is this happening? Any idea in solving such matter?
Thanks in Advance

Michael.
 
H

Herfried K. Wagner [MVP]

* "Michael Chong said:
I have an (exe) executable program created in VB.NET 2003 that calls to a
MFC DLL written in VC++.NET 2003. I always get an error msg
"NullReferenceException: Object Reference Not Set to an Instance of an
Object" when my exe calls the following codes:

in VB.NET

Declare Function test Lib "C:\Cyob\IOComm\Debug\IOComm.dll" _
(ByVal a As Long, ByRef b As Integer) As Integer

'Long' -> 'IntPtr'.
 

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