none
KeyNotFoundException : "The given key was not present in the dictionary."

    Question

  • Hi,

     

    In my WPF application, sometimes I got the following message exception with the following message when I call :

    UIElement.RaiseEvent...

    The associated message is : "The given key was not present in the dictionary."

    The exception : KeyNotFoundException

    The problem is that there is no stack information, nor any other information in the exception. It occur surely in the WPF core code... and surely related to some of my custom controls... but what and where ?

    Do you have an idea to debug this problem ?

    Thanks for your ideas

    Wednesday, July 28, 2010 2:48 PM

All replies

  • Hi,

    Have tried to look on the Output window?  Some silent exceptions can be found here and specifies which object have you got the exception.

    You might also look to your Dictionaries or Resources where one of your controls having a reference binding which cannot be located at your resources.

    Hope this helps.

    Regards,

    gioVhan


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, July 28, 2010 2:55 PM
  • Hi PL 01,

    Have you checked out the giovhan's solution yet?

    It is hard to know the cause of this exception with any code/structure of your application, could you please share some code or could you please descibe your custom controls in details?

    UIElement.RaiseEvent method is used to raise a specific routed event, I am not sure why it can occur the exception related a key in a dictionary? I think you could set a breakpoint the target event of UIElement.RaiseEvent() method, and check whether the dictionary is empty or it contains the key that you want.

    Sincerely,

    Bob Bao

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, August 02, 2010 10:23 AM
  • Hi PL 01,

    Could you please let us know the status of this thread? So that we can follow up this thread.

    Bob Bao


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, August 06, 2010 1:58 AM