System.NullReferenceException , why?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alex J.

    #1

    System.NullReferenceException , why?

    I just started to learn C# (my background is in C++), and right now I
    study the sockets, TCP/IP etc... so, I found a usefull source code at:
    http://www.codeguru.com/Csharp/Cshar...cle.php/c8781/.
    But there is a scenarion that throw a strange exception. So, the client
    is connected to the server, I send a message from client to server and
    viceversa and than I stop the server from the 'x' button from the right-up
    corner; in that moment the client throw System.NullRefe renceException:

    An unhandled exception of type 'System.NullRef erenceException ' occurred
    in system.dll
    Additional information: Object reference not set to an instance of an
    object.

    the cursor is placed here:
    000000a0 0F B6 F0 movzx esi,al

    and the Call Stack stopped here:
    system.dll!Syst em.Net.Sockets. OverlappedAsync Result.Completi onPortCallback( uint
    errorCode = 64, uint numBytes = 0, System.Threadin g.NativeOverlap ped*
    nativeOverlappe d = 1750608) + 0xa0 bytes

    There is a solution?

    Thank you in advance.

    ..:Alex:.


  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: System.NullRefe renceException , why?

    Hi,

    What escenrio?

    What is the code you were executing when this exception is thrown

    That exception happen when you are access a variable that is null


    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "Alex J." <alex_77ro@yaho o.com> wrote in message
    news:%232FjcTWO GHA.2300@TK2MSF TNGP15.phx.gbl. ..[color=blue]
    > I just started to learn C# (my background is in C++), and right now I
    > study the sockets, TCP/IP etc... so, I found a usefull source code at:
    > http://www.codeguru.com/Csharp/Cshar...cle.php/c8781/.
    > But there is a scenarion that throw a strange exception. So, the
    > client is connected to the server, I send a message from client to server
    > and viceversa and than I stop the server from the 'x' button from the
    > right-up corner; in that moment the client throw
    > System.NullRefe renceException:
    >
    > An unhandled exception of type 'System.NullRef erenceException ' occurred
    > in system.dll
    > Additional information: Object reference not set to an instance of an
    > object.
    >
    > the cursor is placed here:
    > 000000a0 0F B6 F0 movzx esi,al
    >
    > and the Call Stack stopped here:
    >
    > system.dll!Syst em.Net.Sockets. OverlappedAsync Result.Completi onPortCallback( uint
    > errorCode = 64, uint numBytes = 0, System.Threadin g.NativeOverlap ped*
    > nativeOverlappe d = 1750608) + 0xa0 bytes
    >
    > There is a solution?
    >
    > Thank you in advance.
    >
    > .:Alex:.
    >[/color]


    Comment

    • Alex J.

      #3
      Re: System.NullRefe renceException , why?

      Hi,

      I don't know if you took a look at the source code from this url:
      http://www.codeguru.com/Csharp/Cshar...cle.php/c8781/
      Try to make 2 projects from these files a client and a server. 'Start
      Listen' the server and then connect the client to the server. Kill the
      server from procesess (task manager).
      You will se how the client throw the exeption in subject:
      System.NullRefe renceException

      Let me know if you understand me.

      Thank you for your attention.

      ..:Alex:.


      "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
      in message news:OS7OEEXOGH A.2992@tk2msftn gp13.phx.gbl...[color=blue]
      > Hi,
      >
      > What escenrio?
      >
      > What is the code you were executing when this exception is thrown
      >
      > That exception happen when you are access a variable that is null
      >
      >
      > --
      > Ignacio Machin,
      > ignacio.machin AT dot.state.fl.us
      > Florida Department Of Transportation
      >
      > "Alex J." <alex_77ro@yaho o.com> wrote in message
      > news:%232FjcTWO GHA.2300@TK2MSF TNGP15.phx.gbl. ..[color=green]
      >> I just started to learn C# (my background is in C++), and right now I
      >> study the sockets, TCP/IP etc... so, I found a usefull source code at:
      >> http://www.codeguru.com/Csharp/Cshar...cle.php/c8781/.
      >> But there is a scenarion that throw a strange exception. So, the
      >> client is connected to the server, I send a message from client to server
      >> and viceversa and than I stop the server from the 'x' button from the
      >> right-up corner; in that moment the client throw
      >> System.NullRefe renceException:
      >>
      >> An unhandled exception of type 'System.NullRef erenceException '
      >> occurred in system.dll
      >> Additional information: Object reference not set to an instance of an
      >> object.
      >>
      >> the cursor is placed here:
      >> 000000a0 0F B6 F0 movzx esi,al
      >>
      >> and the Call Stack stopped here:
      >>
      >> system.dll!Syst em.Net.Sockets. OverlappedAsync Result.Completi onPortCallback( uint
      >> errorCode = 64, uint numBytes = 0, System.Threadin g.NativeOverlap ped*
      >> nativeOverlappe d = 1750608) + 0xa0 bytes
      >>
      >> There is a solution?
      >>
      >> Thank you in advance.
      >>
      >> .:Alex:.
      >>[/color]
      >
      >[/color]


      Comment

      • Alex J.

        #4
        Re: System.NullRefe renceException , why?

        > That exception happen when you are access a variable that is null

        ok, d'accord :), but where exactly it happens in that code?
        Do you have a ideea?


        "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
        in message news:OS7OEEXOGH A.2992@tk2msftn gp13.phx.gbl...[color=blue]
        > Hi,
        >
        > What escenrio?
        >
        > What is the code you were executing when this exception is thrown
        >
        > That exception happen when you are access a variable that is null
        >
        >
        > --
        > Ignacio Machin,
        > ignacio.machin AT dot.state.fl.us
        > Florida Department Of Transportation
        >
        > "Alex J." <alex_77ro@yaho o.com> wrote in message
        > news:%232FjcTWO GHA.2300@TK2MSF TNGP15.phx.gbl. ..[color=green]
        >> I just started to learn C# (my background is in C++), and right now I
        >> study the sockets, TCP/IP etc... so, I found a usefull source code at:
        >> http://www.codeguru.com/Csharp/Cshar...cle.php/c8781/.
        >> But there is a scenarion that throw a strange exception. So, the
        >> client is connected to the server, I send a message from client to server
        >> and viceversa and than I stop the server from the 'x' button from the
        >> right-up corner; in that moment the client throw
        >> System.NullRefe renceException:
        >>
        >> An unhandled exception of type 'System.NullRef erenceException '
        >> occurred in system.dll
        >> Additional information: Object reference not set to an instance of an
        >> object.
        >>
        >> the cursor is placed here:
        >> 000000a0 0F B6 F0 movzx esi,al
        >>
        >> and the Call Stack stopped here:
        >>
        >> system.dll!Syst em.Net.Sockets. OverlappedAsync Result.Completi onPortCallback( uint
        >> errorCode = 64, uint numBytes = 0, System.Threadin g.NativeOverlap ped*
        >> nativeOverlappe d = 1750608) + 0xa0 bytes
        >>
        >> There is a solution?
        >>
        >> Thank you in advance.
        >>
        >> .:Alex:.
        >>[/color]
        >
        >[/color]


        Comment

        Working...