user1231231412
user1231231412

Reputation: 1659

CrmException: The given key was not present in the dictionary. when opening an existing opportunity

As the title says we're now getting a "CrmException: The given key was not present in the dictionary." error when trying to open an existing opportunity.

This appears to only affect some records as we can still open others. My gut reaction is that one of the picklist values somehow got removed from the system but no way to tell curently.

I guess my question is really, how do I turn this generic error message into something useful to fix the error?

Here's the stack trace in the CRM Trace logs

[2011-12-05 17:00:33.848] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread:   26 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Error | ExceptionConverter.ConvertMessageAndErrorCode
at ExceptionConverter.ConvertMessageAndErrorCode(Exception exception, Int32& errorCode)
at ExceptionConverter.ToSingleFaultOther(Exception exception)
at ExceptionConverter.ToSingleFaultUntyped(Exception exception)
at ExceptionConverter.ConvertToFault(Exception exception)
at ExceptionConverter.TryConvertToFaultExceptionInternal(Exception exception, Boolean createNewFaultException, FaultException`1& faultException)
at FaultHelper.ConvertToFault(Exception exception)
at ErrorInformation..ctor(Exception exception, Uri requestUrl, Boolean logError)
at MainApplication.Application_Error(Object sender, EventArgs eventArguments)
at EventHandler.Invoke(Object sender, EventArgs e)
at HttpApplication.RaiseOnError()
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #B89073F3: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Microsoft.Crm.CrmException: The given key was not present in the dictionary.
>       at            Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.XrmExecuteInternal()

at Microsoft.Crm.Application.Platform.ServiceCommands.RetrieveCommand.Execute() at Microsoft.Crm.Application.Platform.EntityProxy.Retrieve(String[] columns, Guid auditingTransactionId) at Microsoft.Crm.Application.Platform.EntityProxy.Retrieve(String columnSet, Guid auditingTransactionId) at Microsoft.Crm.Application.Platform.EntityProxy.Retrieve(String columnSet) at Microsoft.Crm.Application.Forms.AppForm.FormLoadEvent() at Microsoft.Crm.Application.Forms.AppForm.RaiseDataEvent(FormEventId eventId) at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity) at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, FormDescriptor fd) at Microsoft.Crm.Application.Components.PageHandlers.OpportunityRecordPageHandler.ConfigureFormHandler() at Microsoft.Crm.Application.Components.Utility.GenericEventProcessor.RaiseEvent(String eventName) at Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Upvotes: 1

Views: 7765

Answers (1)

jacobappleton
jacobappleton

Reputation: 538

Yes, if you are getting this exception when the plugin is enabled and not when the plugin is disabled then your plugin is throwing an exception and this is being passed through to the error message you are seeing.

This will most likely occur because you are using a property in your dynamic entity which is not actually in the record you are running the plugin on (in this case an opportunity). Check for things like misspellings or unpublished customisations.

See this link for more information on how to prevent such an error: http://splatto.net/portfolio/blog/post/2010/07/30/0x80040265-The-given-key-was-not-present-in-the-dictionary.aspx

Another great way to test what is causing this exception is to run remote debugging on the plugin to see what throws the exception: http://msdn.microsoft.com/en-us/library/cc151088.aspx

Upvotes: 2

Related Questions