更新ServiceAppointment实体后发出奇怪的错误

时间:2013-12-12 17:13:20

标签: dynamics-crm-2011 dynamics-crm crm dynamics-crm-4 dynamics-crm-online

我们正在尝试将CRM 2011从RU 11更新为RU 14,以便在RU 14准备就绪时能够安装RU 15。一直在解决有关此次更新的各种问题,因为微软在Cross平台上做了相当多的更改,显然自从11岁转为14次。

现在,我的主要问题是我有一个在创建服务约会时同步运行的插件。它负责执行多项操作,例如比较值或使用其他实体的值来填充服务活动记录中的数据。关于奇怪的错误是什么,因为在Post Operations上进行了更改,所以必须完成_service.Update(实体)才能在表单和数据库中看到更改。如果我逐步调试代码,除非代码到达.Update,否则一切都会顺利通过。当调用更新时,CRM会抛出一个意外错误。当我进入TraceLogs时,我发现了这一点:


[2013-12-10 14:49:56.323] Process: w3wp |Organization:3e484d20-6245-e311-8a60-00155d6f6b34 |Thread:   20 |Category: Platform.Sdk |User: 0a51b463-df74-e011-81b3-00155d7a7a17 |Level: Error |ReqId: dca72532-8bed-491c-9295-62211d39a6f6 | VersionedPluginProxyStepBase.Execute  ilOffset = 0x65

at VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)  ilOffset = 0x65
at Pipeline.Execute(PipelineExecutionContext context)  ilOffset = 0x65
at MessageProcessor.Execute(PipelineExecutionContext context)  ilOffset = 0x1C5
at InternalMessageDispatcher.Execute(PipelineExecutionContext context)  ilOffset = 0xE4
at ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)  ilOffset = 0x156
at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, UserAuth userAuth, Guid targetUserId, Boolean traceRequest, OrganizationContext context, Boolean returnResponse)  ilOffset = 0x145
at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)  ilOffset = 0x34
at OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)  ilOffset = 0x24
at InprocessServiceProxy.ExecuteCore(OrganizationRequest request)  ilOffset = 0x34
at SandboxSdkListener.Execute(SandboxCallInfo callInfo, SandboxSdkContext requestContext, String operation, Byte[] serializedRequest)  ilOffset = 0xAC
at   ilOffset = 0xFFFFFFFF
at SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)  ilOffset = 0x241
at DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)  ilOffset = 0x100
at ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)  ilOffset = 0x48
at ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)  ilOffset = 0xC6
at MessageRpc.Process(Boolean isOperationContextSet)  ilOffset = 0x62
at ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext)  ilOffset = 0x256
at ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)  ilOffset = 0xF1
at ChannelHandler.AsyncMessagePump(IAsyncResult result)  ilOffset = 0x39
at AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)  ilOffset = 0x0
at AsyncResult.Complete(Boolean completedSynchronously)  ilOffset = 0xC2
at TryReceiveAsyncResult.OnReceive(IAsyncResult result)  ilOffset = 0x4B
at AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)  ilOffset = 0x0
at AsyncResult.Complete(Boolean completedSynchronously)  ilOffset = 0xC2
at ReceiveAsyncResult.OnReceiveComplete(Object state)  ilOffset = 0x2B
at SessionConnectionReader.OnAsyncReadComplete(Object state)  ilOffset = 0xBC
at AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)  ilOffset = 0x0
at LazyAsyncResult.Complete(IntPtr userToken)  ilOffset = 0x3E
at NegotiateStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)  ilOffset = 0x70
at NegotiateStream.ReadCallback(AsyncProtocolRequest asyncRequest)  ilOffset = 0x68
at FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)  ilOffset = 0x5D
at FixedSizeReader.ReadCallback(IAsyncResult transportResult)  ilOffset = 0x29
at AsyncResult.Complete(Boolean completedSynchronously)  ilOffset = 0xC2
at IOAsyncResult.OnAsyncIOComplete(Object state)  ilOffset = 0x26
at SocketConnection.OnReceiveAsync(Object sender, SocketAsyncEventArgs eventArgs)  ilOffset = 0x57
at SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)  ilOffset = 0x5CB
at SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)  ilOffset = 0x10
at _IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)  ilOffset = 0x3C

>Web Service Plug-in failed in SdkMessageProcessingStepId: {B9CDBB1B-EA3E-DB11-86A7-000A3A5473E8}; EntityName: serviceappointment; Stage: 30; MessageName: Update; AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin, Microsoft.Crm.ObjectModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: **Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.**
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
**Inner Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.**
Parameter name: index
at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at Microsoft.Crm.BusinessEntities.BusinessEntityCollection.get_Item(Int32 index)
at Microsoft.Crm.ObjectModel.CommunicationActivityServiceBase.UpdateCommunicationPartiesInternal(BusinessEntityMoniker moniker, CommunicationActivity activity, ExecutionContext context, ExtensionEventArgs e)
at Microsoft.Crm.ObjectModel.CommunicationActivityServiceBase.UpdateCommunicationParties(Object sender, ExtensionEventArgs e)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.PostUpdateEventHandler.Invoke(Object sender, ExtensionEventArgs e)
at Microsoft.Crm.ObjectModel.GenericActivityServiceBase.UpdateInternal(IBusinessEntity entityInterface, ExecutionContext context)
at Microsoft.Crm.ObjectModel.CommunicationActivityServiceBase.Update(IBusinessEntity entityInterface, ExecutionContext context)
_______________

我已经做了不同的更改,试图找出问题所在,其中包括关闭所有已注册的插件,而不是微软的插件和此插件。关闭表单中的所有JavaScript,以防任何值被更改,使其抛出错误,硬编码状态代码和状态代码,因为在线发现的一些相关问题,评论插件中的所有代码,只留下_service。如果传递了无效值,则更新(实体)但更新仍会抛出错误,而我在网上找到的其他东西似乎是一个解决方案。我一直在犯这个错误已经有一段时间了,并希望有更多的想法与我一起思考这个问题。由于与插件绑定的逻辑,插件必须在后续操作中同步运行。

任何帮助都表示赞赏,如果您需要更多信息以了解可能发生的情况,请告诉我们。

1 个答案:

答案 0 :(得分:4)

我一直在用同样的问题撕掉我的头发。我的相同代码在其他类型的实体上工作正常,因此我将其隔离仅发生在活动(即使用ActivityBase的任何内容)上。这看起来像是CRM内部对象模型中的一个错误(至少存在于UR11,这是我正在运行的版本),在以下情况下会发生:

  • 你正在触发一个插件:
    • 反对活动(约会,服务活动,任务,电子邮件等)或自定义活动类型
    • 创建消息
    • 上触发
    • 运行同步
    • 运行运营后

所有活动实体与存在活动参与者(活动参与者)的其他实体进行比较的功能之一,这些参数是“参加者”,“客户”,有用的电子邮件字段(“收件人”,“CC”等标准字段','BCC'),可以包含许多不同的类型,例如'RequiredAttendee','Organizer','To',但重要的是它也创建一个用于记录'所有者'(有关完整列表,请参阅http://msdn.microsoft.com/en-us/library/gg328549.aspx

在查看正在执行的SQL之后(以及在Microsoft.Crm.ObjectModel中的.NET反编译器中偷偷摸摸地查看),看来问题在于活动方是(或不是)的顺序正在创建或更新。对于 之后的活动,通常的Create()消息处理(包括您的插件代码)已完成执行,这些ActivityParty记录(包括所有者的一个)将从实体数据中填充。在Update()上还有一个检查来处理ActivityParties所需的任何更改,但是这(错误地)假定已经创建了ActivityParty记录。

..所以如果你在Create消息中调用Update,那么在Update ActivityParty抛出它的ArgumentOutOfRangeException之前,初始的Create消息还没有完成,因为它还没有任何记录。

这也解释了为什么它在异步模式下按预期工作,因为ActivityParties是在通常的Create()过程之后但在插件执行代码触发的Update运行几秒之后成功创建的。

根据您尝试实现的目标,可以通过改变您的插件来改变预操作事件。