"The given key was not present in the dictionary." Error

FadiFadi Posts: 10 Bronze 1
I recently updated SQL Prompt to version 10.10, and shortly afterwards I started getting the enclosed error every time I execute a query:

The query runs fine, but I have to hit the cancel button multiple times to get rid of the error.

Answers

  • choohj70choohj70 Posts: 3 New member
    I have the same issue. Tried uninstalling and reinstalling SQL Prompt as well.
  • Hi @Fadi, @choohj70

    To help troubleshoot this issue we'll need to take a look at your log files. This documentation shows you where to find them:
    https://documentation.red-gate.com/sp/troubleshooting/finding-the-sql-prompt-log-files

    Please can you send them over to us? If you're not happy posting them in the forum, please send them to support@red-gate.com and a ticket will be raised for you.
    Kind regards

    Victoria Wiseman | Redgate Software
    Have you visited our Help Center?
  • FadiFadi Posts: 10 Bronze 1
    Thank you for reaching out, Victoria. Below is the log associated with the error:
    2022-01-03 10:21:28.045 -05:00 [Error] Report error dialog UI shown
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at RedGate.SqlPrompt.TabHistory.Monitoring.OpenDocuments.GetOpenDocument(IDocumentWrapper document)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.StoreDocument(IDocumentWrapper document, SaveReason saveReason)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.<OnQueryExecuted>b__34_0()
       at RedGate.SQLPrompt.UsageReporting.ErrorReporting.ErrorReporterWithUI.Do(Action action)
    2022-01-03 10:21:30.157 -05:00 [Error] Report error dialog UI shown
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at RedGate.SqlPrompt.TabHistory.Monitoring.OpenDocuments.GetOpenDocument(IDocumentWrapper document)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.StoreDocument(IDocumentWrapper document, SaveReason saveReason)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.<OnQueryExecuted>b__34_0()
       at RedGate.SQLPrompt.UsageReporting.ErrorReporting.ErrorReporterWithUI.Do(Action action)
    2022-01-03 10:21:30.983 -05:00 [Error] Report error dialog UI shown
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at RedGate.SqlPrompt.TabHistory.Monitoring.OpenDocuments.GetOpenDocument(IDocumentWrapper document)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.StoreDocument(IDocumentWrapper document, SaveReason saveReason)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.<OnQueryExecuted>b__34_0()
       at RedGate.SQLPrompt.UsageReporting.ErrorReporting.ErrorReporterWithUI.Do(Action action)
    2022-01-03 10:21:31.861 -05:00 [Error] Report error dialog UI shown
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at RedGate.SqlPrompt.TabHistory.Monitoring.OpenDocuments.GetOpenDocument(IDocumentWrapper document)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.StoreDocument(IDocumentWrapper document, SaveReason saveReason)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.<OnQueryExecuted>b__34_0()
       at RedGate.SQLPrompt.UsageReporting.ErrorReporting.ErrorReporterWithUI.Do(Action action)

  • Hi Fadi,

    Thank you for reaching out!

    Do you happen to have a folder on your machine under the following directory: "C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Data.SQLite"

    The reason I ask is the customer went through a few steps to remove this folder, which eventually fixed their issue.

    The reason being, it appears that if there's a version of a .dll in the GAC, then .NET will always load that version first. We do package the .dll in our tools, but if that exists, it's possible it's trying to pull that .dll instead.

    Thank you!


  • FadiFadi Posts: 10 Bronze 1
    Hi dkim,

    There's no folder with that name under GAC_MSIL.
  • choohj70choohj70 Posts: 3 New member
    edited January 4, 2022 6:45PM
    Hello, dkim,

    I do not have that folder either. However, the verbose logging has identified a potential issue. It states:

    2022-01-04 10:04:42.156 -08:00 [Warning] Could not find table 1502680451 for PK column 1 - perhaps it's on a table type
    2022-01-04 10:04:42.156 -08:00 [Warning] Could not find table 1502680451 for PK column 2 - perhaps it's on a table type

    Validated that these are actually the primary keys for table types. Could these be the cause of the issue?

    Thanks
  • Hi @Fadi and @choohj70 ,

    Thank you for the update.

    As the error message "The given key was not present in the dictionary" is a broad error message, it is difficult to diagnose the issue with just that.

    If possible, can you send over your complete log files? If you're not happy posting them in the forum, please send them to support@red-gate.com and a ticket will be raised for you.

    Thank you!





  • choohj70choohj70 Posts: 3 New member
    I was just prompted to upgrade my SQL Prompt to 10.10.3.25844.
    Once I did that, the error message disappeared. 

    The information below is from before the upgrade.

    2022-01-04 10:07:31.290 -08:00 [Error] Report error dialog UI shown
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at RedGate.SqlPrompt.TabHistory.Monitoring.OpenDocuments.GetOpenDocument(IDocumentWrapper document)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.StoreDocument(IDocumentWrapper document, SaveReason saveReason)
       at RedGate.SqlPrompt.TabHistory.Monitoring.TabWatcher.<OnQueryExecuted>b__34_0()
       at RedGate.SQLPrompt.UsageReporting.ErrorReporting.ErrorReporterWithUI.Do(Action action)

    At this point, it seems like the new version has addressed the issue.

    Thank you!

  • Thank you for the update.

    I am glad to hear that updating fixed the issue for you.

    If you have any other questions feel free to reach out.

    Thank you!

    -David Kim
Sign In or Register to comment.