vaibhav shah
vaibhav shah

Reputation: 5069

The given key was not present in the dictionary error when running application in windows server 2008 r2

I have one web application made using MVC3 Razor.

Application starts properly in browser but after put some values in text box & click on search button I get error as

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

This happens only in Windows server 2008 R2. In other Os like windows 7, Windows server 2008 sp1 it works fine.

Below is the Stack Trace

[KeyNotFoundException: The given key was not present in the dictionary.]
   System.Collections.Generic.Dictionary`2.get_Item(TKey key) +12686831
   CVR_Prototype.Controllers.HomeController.CvrDetailsCompleted() +171
   lambda_method(Closure , ControllerBase , Object[] ) +79
   System.Web.Mvc.Async.<>c__DisplayClass7.<BeginExecute>b__5(IAsyncResult asyncResult) +288
   System.Web.Mvc.Async.<>c__DisplayClass41.<BeginInvokeAsynchronousActionMethod>b__40(IAsyncResult asyncResult) +22
   System.Web.Mvc.Async.<>c__DisplayClass3b.<BeginInvokeActionMethodWithFilters>b__35() +129
   System.Web.Mvc.Async.<>c__DisplayClass51.<InvokeActionMethodFilterAsynchronously>b__4b() +810887
   System.Web.Mvc.Async.<>c__DisplayClass51.<InvokeActionMethodFilterAsynchronously>b__4b() +810887
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__38(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2c.<BeginInvokeAction>b__22() +33
   System.Web.Mvc.Async.<>c__DisplayClass27.<BeginInvokeAction>b__24(IAsyncResult asyncResult) +811468
   System.Web.Mvc.<>c__DisplayClass19.<BeginExecuteCore>b__14(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
   System.Web.Mvc.AsyncController.EndExecuteCore(IAsyncResult asyncResult) +67
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
   System.Web.Mvc.AsyncController.EndExecute(IAsyncResult asyncResult) +53
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__4(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

Upvotes: 1

Views: 3860

Answers (1)

Yasser Shaikh
Yasser Shaikh

Reputation: 47794

Source : http://shahvaibhav.com/solving-the-given-key-was-not-present-in-the-dictionary-error-of-visual-studio-2010/

While developing mvc3 razor application I came across one strange error “The given key was not present in the dictionary”.

After searching in google for hours I found the solution for this error.

Actually this error means that “This typically means that you’ve installed a custom data provider, created a Server Explorer connection using that provider, and then uninstalled the provider without deleting the Server Explorer entry” To solve this error 1st thing you have to do is close all visual studio instances.

Now go to your user AppData directory (e.g. C:\Users\Administrator\AppData) (Notice: AppData may not be shown in windows explorer if you have “Show hidden files and folders” turned off)

n AppData go to Roaming > Microsoft > Visual Studio > 10.0 > ServerExplorer

There you will find file named DefaultView.SEView. This files stores all connections.

This is a plain XML file, so in theory, you can locate the dud connection by its Label and just remove the containing DataViewNode XML element. In practice, I didn’t have much luck with this – the file stores blobs against connections by index, so deleting individual items can throw those indexes off. But if you’ve got a lot of connections defined and you don’t want to have to recreate them, it’s probably worth giving this a try in case you get luckier than I did. Otherwise, just delete the DefaultView.SEView file.

Now restart visual studio & its done . Now you are free from that bad error.

Upvotes: 1

Related Questions