荫得到OutOfMemoryException异常,同时使远程方法调用。

“RemoteEntity.SetLocalStore(数据集);”

传递的值是数据集。

请注意数据集的大小是38MB

Envoirment C#VS2008

由于

代码:

private void backgroundSync_DoWork(object sender, DoWorkEventArgs e)
        {            
            backgroundSync.ReportProgress(10, "Fetching data for sync ...");
            EngagementSet _remoteSet = HKMPClient.Instance.RemoteEntity.GetLocalStore();



            //Update to release memory.
            HKMPClient.Instance.RemoteEntity.SetLocalStore(null);
            //dispose RemoteEntity
            HKMPClient.Instance.DisconnectAndDispose();

            HKMP.EngagementWorks.Windows.BLL.Engagements.Engagement.MergeEntitiesInLimitedConnecitivity(_remoteSet,EngagementID);            
            backgroundSync.ReportProgress(10, "Synchronizing Engagement ...");
            DialogSync _dlgSync = new DialogSync(this.EngagementID, _remoteSet);
            _dlgSync.ServiceRequestStarted += new DialogSync.OnServiceRequestStarted(_dlgSync_ServiceRequestStarted);
            _dlgSync.ServiceRequestCompleted += new DialogSync.OnServiceRequestCompleted(_dlgSync_ServiceRequestCompleted);
            if (_dlgSync.IsShown())
            {
                _dlgSync.StartPosition = FormStartPosition.CenterParent;
                _dlgSync.WindowState = FormWindowState.Normal;
                _dlgSync.ShowDialog();
            }
            //Disposed to release object.
            _dlgSync.Dispose();
            _dlgSync = null;


            // connect again                
            HKMPClient.Instance.Connect(e.Argument.ToString());

            _remoteSet.RemotingFormat = SerializationFormat.Binary;

            HKMPClient.Instance.RemoteEntity.SetLocalStore(_remoteSet);

        }
有帮助吗?

解决方案

我认为你知道答案,38MB是太大了做了一个远程调用。怎样才能帮助诊断它进一步将是simplfying你的问题,只是两种功能在本地运行,显示一个完整的例子。

这将帮助检测,如果它是数据集的大小,或在远程接口/网络配置的尺寸约束。

此外有工作示例将允许别人复制这个问题,看看类型的信息(例如,我们看不到什么对象类型抛出异常,不能查找任何约束MSDN)。我敢肯定,这个人将能够提供一个明确的答案。

减少你的代码样本本身将可能使您能够找到原因的行为。

赖安

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top