.Net 1.1 TcpClient strangeness

There seems to be a wierd bug with .Net 1.1 and sockets…

In essence, this code:

using System;
using System.Net.Sockets;

namespace ConsoleClient;
{
 class Class1
 {
  [STAThread]
  static void Main(string[] args)
  {
   TcpClient _socket = new TcpClient();
  }
 }
}

works with .Net 1.0 and fails with .Net 1.1. The error message on 1.1 is this; “Additional information: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full”, which is the long version of WSAENOBUFS.

This seems to have been around for ages, only affects some machines and my searching has yet to turn up an official response from someone at MS…

The only “successful” fix I’ve seen mentioned is here, and, well, excuse me if I don’t relish the thought of “Resetting” my TCP/IP stack when there’s no explaination as to why it’s become “corrupted” and no detail of why this ONLY seems to affect the .Net 1.1 libraries…

Luckilly I can simply switch back to .Net 1.0 for now because switching this particular piece of code to 1.1 was just for convenience. You see, it all started like this…

I needed to add a new protocol test to my C# socket server test harness. It was about 30 mins work to actually add the new test but I decided that since I had some time on my hands I’d migrate the source from source safe to CVS (I’d started this migration a while ago but work got busy and some things didn’t get migrated and are still on my list of things to do, I thought I’d knock one off…).

Anyway, I moved the source to CVS and then I wanted to disconnect the project files from Source Safe. I remembered that the GUI for doing this was more intuitive in VS.Net 2003 than in VS.Net Classic and, since there was no need to maintain a VS.Net Classic project file for this particular piece of code I decided to just upgrade to VS.Net 2003, allow the nice GUI prompt to disconnect my project files cleanly and then continue in the brave new (ish) world of .Net 1.1.

Except that sockets don’t work on my main development machine in .Net 1.1 (they work on my laptop, go figure…) and the whole reason for this blob of code’s existence is to do socket things. You’d think sockets were one of those things that was quite important to MS now, what with all the noise they’re making about web services, but…

I guess since there isn’t much .Net 1.1 code out in the wild the problem doesn’t show up that often. However, it may explain why SharpReader v9.3 (the .Net 1.1 build) doesn’t work on my box (it hangs, possibly because it fails to create a socket and the exception is just swallowed somewhere…)

Bleugh…