0

I am trying to write a simple chat client and server program, using this link - http://csharp.net-informations.com/communications/csharp-chat-server-programming.htm (2 links to source code for server and client are just under the pictures). But when I try to compile I get an error in this line

serverStream.Write(outStream, 0, outStream.Length);

Here I get below error

NullRefrenceException [Object reference not set to an instance of an object].

but right above I have a line

byte[] outStream = System.Text.Encoding.ASCII.GetBytes(textBox2.Text);

which successfully initializes the outStream. So I'm really not sure of what is causing this, and will be glad if someone could help me.

Dirk
  • 9,949
  • 2
  • 29
  • 45
Dmetrey
  • 29
  • 1
  • 6
  • Maybe the null ref is `serverStream` and not `outStream`. Check both these variables at runtime. – Johnny Mopp Mar 08 '14 at 14:31
  • Also take a look at [this question and answer](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it). – Dirk Mar 08 '14 at 14:35

0 Answers0