System.NullReferenceException , why?

A

Alex J.

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/Csharp/cs_network/sockets/article.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.NullReferenceException:

An unhandled exception of type 'System.NullReferenceException' 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!System.Net.Sockets.OverlappedAsyncResult.CompletionPortCallback(uint
errorCode = 64, uint numBytes = 0, System.Threading.NativeOverlapped*
nativeOverlapped = 1750608) + 0xa0 bytes

There is a solution?

Thank you in advance.

..:Alex:.
 
I

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

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
 
A

Alex J.

Hi,

I don't know if you took a look at the source code from this url:
http://www.codeguru.com/Csharp/Csharp/cs_network/sockets/article.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.NullReferenceException

Let me know if you understand me.

Thank you for your attention.

..:Alex:.
 
A

Alex J.

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?
 

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