Alex Rivera | Logout

When KeyNotFoundException is thrown, how do I see which key wasn't found?

Asked 2011-08-29T12:19:13.493
41

A System.Collections.Generic.Dictionary is throwing KeyNotFoundException, but I can't see which key is supposedly missing. How do I determine this?

Edit
Report

1 Answer

3

You can't just by looking at the exception. You will have to break into the debugger when the exception is thrown (Debug -> Exceptions... in Visual Studio) and see what key has been accessed. Alternatively you could catch the exception in code and print it out (e.g. to the console).

answered 2011-08-29T12:20:44.697

Your Answer