[Mono-dev] Socket has a dynamic GetHashCode method

Robert Jordan robertj at gmx.net
Mon Aug 13 18:16:44 EDT 2007

David Wolinsky wrote:
> Socket relies on the underlying operating system handle for its 
> HashCode, this creates a problem if later after the underlying resource 
> has been disposed but the Socket object is still in use....
> For example...
> Hashtable ht = new Hashtable();
> Socket s = new Socket(...);
> ht[s] = 5;
> Console.WriteLine(ht.Contains(s)); // true
> s.Close();
> Console.WriteLine(ht.Contains(s)); // false
> Is this a bug or an expected result?

This is expected under .NET 1.1. Under .NET 2.0, MS has removed
the overloaded GetHashCode, like in the attached patch.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Socket.diff
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070814/dbfa496e/attachment.pl 

More information about the Mono-devel-list mailing list