【问题标题】:FetchXml System.OutOfMemory ExceptionFetchXml System.OutOfMemory 异常
【发布时间】:2012-07-21 13:06:39
【问题描述】:

正如我从 Google 搜索中了解到的,MSCRM 2011 最多检索 5000 个实体,但我希望我的所有实体都来自营销列表。正如网上所写,在 HKLM\Software\Microsoft\MSCRM 上创建“TurnOffFetchThrottling”字段并将值设置为 1 可以解决此 5000 限制问题(此外,我在注册表中添加了 MaxRowsPerPage 字段并将其值设置为大于 5000,但它也不起作用)。我试过了,我得到了 System.OutOfMemory Exception 错误。顺便说一句,当我删除“”并获得 id 属性代码时效果很好,但我需要所有属性。这是我的 fetchxml 代码:

enter code here
string fetchXml = "<fetch mapping='logical' >"
                  + "<entity name='" + entityType.LogicalName + "'>"
                    + "<all-attributes />"
                    + "<link-entity name='listmember' to='" + entityType.LogicalName + "id" + "' from='entityid'>"
                        + "<filter>"
                          + "<condition attribute='listid' operator='eq' value='" + chosenMarketingListGuid + "'/>"
                        + "</filter>"
                    + "</link-entity>"
                  + "</entity>"
                + "</fetch>";

我又尝试了一件事,我把 fetchxml 改成了:

enter code here
string fetchXml = "<fetch mapping='logical' >"
                  + "<entity name='listmember'>"
                    + "<all-attributes />"
                        + "<filter>"
                          + "<condition attribute='listid' operator='eq' value='" + chosenMarketingListGuid + "'/>"
                        + "</filter>"
                  + "</entity>"
                + "</fetch>";

正如所见,我尝试仅检索成员列表而不是联系人/潜在客户/帐户实体类型,并且它有效!但是,我需要联系人/潜在客户/帐户实体类型而不是成员列表。 如果有人能帮助我走出这条黑暗的 MSCRM 隧道,我将不胜感激!

这里,完整的堆栈跟踪:

[OutOfMemoryException:引发了“System.OutOfMemoryException”类型的异常。] System.ServiceModel.Security.SecurityUtils.ReadContentAsBase64(XmlDictionaryReader 阅读器,Int64 maxBufferSize)+197 System.ServiceModel.Security.EncryptedData.ReadCipherData(XmlDictionaryReader reader, Int64 maxBufferSize) +17 System.ServiceModel.Security.EncryptedType.ReadFrom(XmlDictionaryReader reader, Int64 maxBufferSize) +858 System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.DecryptBody(XmlDictionaryReader bodyContentReader, SecurityToken token) +80 System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.ExecuteMessageProtectionPass(Boolean hasAtLeastOneSupportingTokenExpectedToBeSigned) +1611 System.ServiceModel.Security.ReceiveSecurityHeader.Process(时间跨度超时,ChannelBinding channelBinding,ExtendedProtectionPolicy extendedProtectionPolicy)+1576 System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(ReceiveSecurityHeader securityHeader, Message& message, SecurityToken requiredSigningToken, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates) +205 System.ServiceModel.Security.SymmetricSecurityProtocol.VerifyIncomingMessageCore(消息和消息,字符串演员,时间跨度超时,SecurityProtocolCorrelationState[] 相关状态)+637 System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(消息和消息,TimeSpan 超时,SecurityProtocolCorrelationState[] 相关状态)+371 System.ServiceModel.Channels.SecurityRequestChannel.ProcessReply(消息回复,SecurityProtocolCorrelationState 相关状态,TimeSpan 超时)+471 System.ServiceModel.Channels.SecurityRequestChannel.Request(消息消息,TimeSpan 超时)+175 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) +22 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) +517 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) +88 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)+453 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) +237 Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple(QueryBase 查询)+0 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase 查询)+626 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultiple(QueryBase 查询)+39 C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\MarketingListHelper.cs:130 中的 IMPlugin.MarketingListHelper.getMembersAndCountOfChosenMarketingList(OrganizationServiceProxy 服务,Guid selectedMarketingListGuid,实体 entityType) C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\IM_SMS.aspx.cs:96 中的 IMPlugin.IM_SMS.fillMainPanel(Double mainPanelHeight) C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\IM_SMS.aspx.cs:42 中的 IMPlugin.IM_SMS.Page_Load(Object sender, EventArgs e) System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,对象 o,对象 t,EventArgs e)+14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者,EventArgs e)+35 System.Web.UI.Control.OnLoad(EventArgs e) +91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

【问题讨论】:

    标签: dynamics-crm dynamics-crm-2011 fetchxml


    【解决方案1】:

    存在 5000 限制的原因是作为一个粗略的障碍来防止您遇到的问题。您已经绕过了软件限制,现在需要克服硬件限制(内存不足)...

    您没有说明您是如何编写代码或将结果用于什么目的,但我认为执行查询后会有额外的处理。在此基础上,我的建议是您在查询表达式中引入分页,分批处理 5000 条记录。

    一个粗略的例子:

    // get records to process
    string pagingCookie = null;
    bool moreRecords = false;
    int pageNum = 1;
    DataCollection<Entity> myBatchOfRecords;    
    
    bool continueProcessing = true;
    while (continueProcessing)
    {
        myBatchOfRecords = GetRecords(pageNum, ref pagingCookie, ref moreRecords);
    
        // process those records
        ProcessRecords(myBatchOfRecords);
        pageNum++;    
        continueProcessing = moreRecords;
    }
    
    function DataCollection<Entity> GetRecordsList(int pageNumber, ref string pagingCookie, ref bool moreRecords){
        var query = new QueryExpression(blahblahblah...);
        query.PageInfo = new PagingInfo { 
            Count = 5000, 
            PageNumber = pageNumber, 
            PagingCookie = pagingCookie };
        var results =  myOrgService.RetrieveMultiple(query);
        pagingCookie = matchedContacts.PagingCookie;
        moreRecords = matchedContacts.MoreRecords;
        return results;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-21
      • 1970-01-01
      • 1970-01-01
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多