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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Chong

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

    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
    "NullReferenceE xception: 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.d ll" _
    (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.


  • Herfried K. Wagner [MVP]

    #2
    Re: ERROR: Object Reference Not Set to an Instance of an Object

    * "Michael Chong" <michael@cyob.c om.my> scripsit:[color=blue]
    > 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
    > "NullReferenceE xception: 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.d ll" _
    > (ByVal a As Long, ByRef b As Integer) As Integer[/color]

    'Long' -> 'IntPtr'.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    Working...