Exception in TcpServer when it tries to rename the Thread.

Jun 9, 2010 at 9:04 PM

I'm seeing a really odd error that I don't know enough about SharedCache to explain.

 

When I do a request from the client, The server ends up throwing this exception:

   The type initializer for 'SharedCache.WinService.ServiceLogic' threw an exception.
   at SharedCache.WinService.TcpServer.HandleClientMessage(SharedCacheStateObject state) in C:\zip_code_cs_25909_release_3.0.5.1\SharedCache.WinService\TcpServer.cs:line 872
   -Inner Exception-
   This property has already been set and cannot be modified.
      at System.Threading.Thread.set_Name(String value)
   at SharedCache.WinService.TcpServerReplication..ctor() in C:\zip_code_cs_25909_release_3.0.5.1\SharedCache.WinService\TcpServerReplication.cs:line 145
   at SharedCache.WinService.ServiceLogic..cctor() in C:\zip_code_cs_25909_release_3.0.5.1\SharedCache.WinService\ServiceLogic.cs:line 73

Looking at the code at these lines, it looks like TcpServerReplication is trying to name the thread:

Thread.CurrentThread.Name = "TcpServerReplication";
However, the thread is already named "TcpServer (static)", so it can't set the name again.

More importantly, the place that this exception is thrown in TcpServer.HandleClientMessage() causes it to exit without closing the Socket's response, so the client how hangs indefinitely trying to read the Socket response! Looking at that method, and the way the Socket is passed around to different delegates, there are probably a few other places where an unhandled exception will cause the client to hang because the socket's response is never closed.

 

Anyone have any ideas? Thanks for any help!

-Jeff