[Mono-list] Duplicate keys in hashtable when using Castle Monorail with Brail view engine

Simon Lindgren simon.n.lindgren at gmail.com
Thu Apr 22 19:33:55 EDT 2010


tor 2010-04-22 klockan 21:40 +0200 skrev Robert Jordan:
> On 22.04.2010 19:57, Simon Lindgren wrote:
> > 	string path = "path";
> > 	try {
> 
> This is a very interesting way of iterating over a dictionary ;)

Indeed :)

> 
> > 		for (IDictionaryEnumerator n = parameters.GetEnumerator(); ;) {
> > 			n.MoveNext();
> > 			if (((string)n.Value) == "/Page1") {
> > 				Console.WriteLine("path.GetHashCode(): {0}", path.GetHashCode());
> > 				Console.WriteLine("Key.GetHashCode(): {0}", n.Key.GetHashCode());
> > 				Console.WriteLine("Key.Equals(path): {0}", n.Key.Equals(path));
> > 				Console.WriteLine("ReferenceEquals(Key, path): {0}", ReferenceEquals(n.Key, path));
> > 				Console.WriteLine("Key == path: {0}", n.Key == path);
> 
> n.Key == path will always be false here, because String.Equals
> will *not* be called.

Not really an error, just me forgetting to remove it after adding the
ReferenceEquals call...

> 
> You must cast n.Key to string:
> 
> 	(string)n.Key == path
> 
> Check your code for similar errors and if you still think you've
> found a bug, please file a case in Bugzilla with a self-contained
> test case anyone can compile.

I don't know how to reproduce this without the ASP.NET stack or the
dozen libs that is required for the Castle Framework. The code for this
is pretty small though, something like 200 lines or so including
configuration, but I don't believe it can be automated very easily.

The fact remains that I can get what seems to be a duplicate key into a
Hashtable, so something is not right, but I don't really know what to
try next.

-- 
Simon Lindgren
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Detta =?ISO-8859-1?Q?=E4r?= en digitalt signerad
	meddelandedel
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20100423/92ad79fb/attachment.bin 


More information about the Mono-list mailing list