正如标题所说,我们现在得到的是“CrmException:字典中没有给定的密钥。”尝试打开现有机会时出错。
这似乎只影响一些记录,因为我们仍然可以打开其他记录。我的直觉反应是,其中一个选项列表值以某种方式从系统中删除但没有办法告诉我们。
我想我的问题是,如何将此通用错误消息转换为修复错误的有用信息?
这是CRM跟踪日志中的堆栈跟踪
[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() 在Microsoft.Crm.Application.Platform.EntityProxy.Retrieve(String []列,Guid auditingTransactionId) 在Microsoft.Crm.Application.Platform.EntityProxy.Retrieve(String columnSet,Guid auditingTransactionId) 在Microsoft.Crm.Application.Platform.EntityProxy.Retrieve(String columnSet) 在Microsoft.Crm.Application.Forms.AppForm.FormLoadEvent() 在Microsoft.Crm.Application.Forms.AppForm.RaiseDataEvent(FormEventId eventId) 在Microsoft.Crm.Application.Forms.EndUserForm.Initialize(实体实体) 在Microsoft.Crm.Application.Forms.CustomizableForm.Execute(实体实体,FormDescriptor fd) 在Microsoft.Crm.Application.Components.PageHandlers.OpportunityRecordPageHandler.ConfigureFormHandler() 在Microsoft.Crm.Application.Components.Utility.GenericEventProcessor.RaiseEvent(String eventName) 在Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e) 在System.Web.UI.Control.PreRenderRecursiveInternal() 在System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 在System.Web.UI.Page.HandleError(例外e) 在System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 在System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 在System.Web.UI.Page.ProcessRequest() 在System.Web.UI.Page.ProcessRequest(HttpContext上下文) 在System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously)
答案 0 :(得分:2)
是的,如果您在启用插件时收到此异常,而不是在禁用插件时获得此异常,那么您的插件会抛出异常,并且会将其传递给您看到的错误消息。
这很可能是因为您在动态实体中使用了一个属性,该属性实际上并不在您运行插件的记录中(在这种情况下是一个机会)。检查拼写错误或未发布的自定义内容。
有关如何防止此类错误的详细信息,请参阅此链接:http://splatto.net/portfolio/blog/post/2010/07/30/0x80040265-The-given-key-was-not-present-in-the-dictionary.aspx
测试导致此异常的原因的另一个好方法是在插件上运行远程调试以查看抛出异常的内容:http://msdn.microsoft.com/en-us/library/cc151088.aspx