dynamics-crm - FetchXml System.OutOfMemory 异常

标签 dynamics-crm dynamics-crm-2011 fetchxml

据我从 Google 搜索中了解到,MSCRM 2011 最多检索 5000 个实体,但我希望所有实体都来自营销列表。正如网上所写,在 HKLM\Software\Microsoft\MSCRM 上创建“TurnOffFetchThrotdling”字段并将值设置为 1 可以解决这个 5000 限制问题(此外,我在注册表中添加了 MaxRowsPerPage 字段并将其值设置为超过 5000,但它也不起作用)。我尝试了一下,出现 System.OutOfMemory 异常错误。顺便说一句,当我删除“”并获取 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: Exception of type 'System.OutOfMemoryException' was thrown.] System.ServiceModel.Security.SecurityUtils.ReadContentAsBase64(XmlDictionaryReader reader, 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(TimeSpan timeout, 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(Message& message, String actor, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates) +637 System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates) +371 System.ServiceModel.Channels.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) +471 System.ServiceModel.Channels.SecurityRequestChannel.Request(Message message, TimeSpan timeout) +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 message) +453 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +237 Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple(QueryBase query) +0 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase query) +626 Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultiple(QueryBase query) +39 IMPlugin.MarketingListHelper.getMembersAndCountOfChosenMarketingList(OrganizationServiceProxy service, Guid chosenMarketingListGuid, Entity entityType) in C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\MarketingListHelper.cs:130 IMPlugin.IM_SMS.fillMainPanel(Double mainPanelHeight) in C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\IM_SMS.aspx.cs:96 IMPlugin.IM_SMS.Page_Load(Object sender, EventArgs e) in C:\Users\Zafer\Documents\Visual Studio 2010\Projects\IMPlugin\IM_SMS.aspx.cs:42 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, 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

最佳答案

存在 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;
}

关于dynamics-crm - FetchXml System.OutOfMemory 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11610116/

相关文章:

Azure函数错误: Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=7.0.0.0' ?

dynamics-crm-2011 - 在线和内部部署的通用解决方案?

dynamics-crm-2011 - 从汇总 11 升级到汇总 13 时出错 - 已添加具有相同 key 的项目

reporting-services - 如何在 Dynamics CRM 中对字段求和?

c# - 有没有办法在不分页的情况下获取 CRM 中给定类型实体的总数

mysql - 将我的 sql 查询转换为 crm 中的 queryexpression 或 fetchxml

javascript - 错误请求进行 AJAX 调用时 : This. readyState 未定义

java - 使用 Apache Olingo 指定实体类型

c# - 如何在 Dynamics CRM 中将日期时间字段转换为日期?

dynamics-crm - 在 FetchXML 中返回 NULLS