【发布时间】:2014-08-04 19:31:28
【问题描述】:
我在 OpportunityProduct 上有一个插件,可以在创建或更新商品时计算商品的税金。大多数时候它工作正常,但是当我以编程方式添加许多产品时,它有时会失败,但以下例外。
当抛出异常并且它试图锁定的行是在它之前添加的行时,新的机会产品存在于数据库中。我相信正在发生的事情是我添加了一个新产品,然后 CRM 检索所有产品以便有机会计算总数。我不知道使用什么机制来更新总数。它不是一个常规插件,我什至无法看到它在做什么,更不用说改变它了。
这是带有汇总 15(v2) 的 CRM 2011 的本地安装。
有什么想法吗?
谢谢, 比尔
Microsoft.Xrm.Sdk.SaveChangesException:处理此请求时发生错误。 ---> System.ServiceModel.FaultException1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Cannot obtain lock on resource:'OpportunityProduct_dbe8cb25-031c-e411-8f23-002269c5d599', mode:Update - stored procedure sp_getapplock returned error code -3.
Result StackTrace:2 动作)
在 Microsoft.Xrm.Client.Services.OrganizationService.Execute(组织请求请求)
在 Microsoft.Xrm.Client.Services.CachedOrganizationService.InnerExecute(组织请求请求)
在 Microsoft.Xrm.Client.Services.OrganizationServiceCache.InnerExecute[TRequest,TResponse,TResult](TRequest 查询,Func
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.ExecuteCore(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.Execute(OrganizationRequest request)
at Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClass19.<Execute>b__18(IOrganizationService s)
at Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func2 execute, Func2 选择器)
在 Microsoft.Xrm.Client.Services.OrganizationServiceCache.InnerExecute[TRequest,TResponse,TResult](TRequest 请求,Func2 execute, Func2 选择器,字符串 selectorCacheKey)
在 Microsoft.Xrm.Client.Services.OrganizationServiceCache.Execute[T](OrganizationRequest 请求,Func2 execute, Func2 选择器,字符串 selectorCacheKey)
在 Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest 请求,Func5 execute, Func2 选择器,字符串 selectorCacheKey)
在 Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest 请求,Func2 selector, String selectorCacheKey)
at Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute[T](OrganizationRequest request)
at Microsoft.Xrm.Client.Services.CachedOrganizationService.Execute(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
at Microsoft.Xrm.Client.CrmOrganizationServiceContext.Microsoft.Xrm.Sdk.IOrganizationService.Execute(OrganizationRequest )
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.Execute(OrganizationRequest request)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChange(OrganizationRequest request, IList1 结果)
--- 内部异常堆栈跟踪结束 ---
在 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges(SaveChangesOptions 选项)
在 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges()
在 RenewalUnitTests.CrmTest.CreateProposalServiceCode(Guid proposalId,字符串 serviceCodeNumber,字符串 servicePeriodNumber,字符串 servicePeriodNumber2,Int32 数量,字符串 uomName)在 c:\Code\ktfs1\Projects\CRM\DEV\Renewal\RenewalUnitTests\CrmTest.cs:line 373
在 c:\Code\ktfs1\Projects\CRM\DEV\Renewal\RenewalUnitTests\BridgestoneTests.cs:line 190 中的 BridgestoneUnitTests.BridgestoneTests.EmailSimpleProposal() 处
【问题讨论】: