throw; // this rethrows the caugh exception.
// here you will get the same exception as you got in the
// other catch.
// Note that I used throw; to rethrow the exception. If on the
// other catch I did a throw exception; I would end-up replacing
// the stored callstack (that's usually a bad thing).
Note: You can also avoid catching the exception by putting a more specific type in the first catch (like IOException instead of Exception).
Hey folks!! Hope you can help me with my client code.
Först I debugg the Server wich is an consoleapplication and the server starts, secondly I debugg the Client, I put a nickname value to the nickNameTextBox and click on Connect (button2) the compiler stops at this code line
from the button 2 handler - unless you have pressed Button1 first, the connection has not been established and it will likely throw an exception - probably the one you are complaining about.
Personally, I would have a "Connect" method, which checked if you are connected and does so if not - and call it from both click events. (I would probably also make it return the stream instead of using a class level variable directly in the two event handlers).
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.