openair icon indicating copy to clipboard operation
openair copied to clipboard

System.ArgumentNullException: 缓冲区不能为 null。

Open zhmi19811015 opened this issue 4 years ago • 3 comments

` IEnumerable<CityAQIPublishLive> citylives = await publishCtx.Load(publishCtx.GetCityAQIPublishLivesQuery()).ResultAsync();

        Console.Write("\r\n进行下一阶段演示:"); Console.ReadLine(); Console.Clear();
        AQIDataPublishLive[] sizeData = null;
        //sizeData = await publishCtx.GetAirByCity(230600).ResultAsync<AQIDataPublishLive[]>().ConfigureAwait(false);


        //根据城市code获取所有检测站的空气数据
        //AQIDataPublishLive[] sizeData = null;
        //string ab = "230600";
        foreach (var c in citylives) {
            //IEnumerable<AQIDataPublishLive> sitess = await publishCtx.Load(publishCtx.GetAirByCity(c.CityCode)).ResultAsync();

            Console.WriteLine("CityCode:" + c.CityCode);
            sizeData = await publishCtx.GetAirByCity(c.CityCode).ResultAsync<AQIDataPublishLive[]>(); 
            
        }

`

执行上述foreach循环时报以下错误

CityCode:220300 CityCode:220400 CityCode:220500 CityCode:220600 CityCode:220700 CityCode:220800 CityCode:222400 CityCode:230100 CityCode:230200 CityCode:230300 CityCode:230400 CityCode:230500 CityCode:230600

未经处理的异常: 未经处理的异常: OpenRiaServices.DomainServices.Client.DomainOperationException: Invoke operation 'GetAirByCity' failed. 引发类型为“OpenRiaServices.DomainServices.Client.DomainOperationException”的异常。 在 OpenRiaServices.DomainServices.Client.OperationBase.Complete(Exception error) 位置 C:\Users\danie\GitHub\openriaservices\OpenRiaServices.DomainServices.Client\Framework\Silverlight\OperationBase.cs:行号 299 在 OpenRiaServices.DomainServices.Client.InvokeOperation.Complete(Exception error) 位置 C:\Users\danie\GitHub\openriaservices\OpenRiaServices.DomainServices.Client\Framework\Silverlight\Data\InvokeOperation.cs:行号 212 在 OpenRiaServices.DomainServices.Client.DomainContext.CompleteInvoke(IAsyncResult asyncResult) 位置 C:\Users\danie\GitHub\openriaservices\OpenRiaServices.DomainServices.Client\Framework\Silverlight\Data\DomainContext.cs:行号 1073 在 OpenRiaServices.DomainServices.Client.DomainContext.<>c__DisplayClass61_1.<InvokeOperation>b__2(Object ) 位置 C:\Users\danie\GitHub\openriaservices\OpenRiaServices.DomainServices.Client\Framework\Silverlight\Data\DomainContext.cs:行号 1026 在 System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) 在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 在 System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 在 System.Threading.ThreadPoolWorkQueue.Dispatch() 在 System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() System.AggregateException: 发生一个或多个错误。 ---> System.ArgumentNullException: 缓冲区不能为 null。 参数名: buffer 在 System.IO.MemoryStream..ctor(Byte[] buffer, Boolean writable) 在 System.IO.MemoryStream..ctor(Byte[] buffer) 在 Com.Hzexe.Air.OpenAirLibrary.EntityQueryExt.Decompress(Byte[] baseBytes) 在 Com.Hzexe.Air.OpenAirLibrary.EntityQueryExt.<>c__DisplayClass1_01.<ResultAsync>b__0() 在 System.Threading.Tasks.Task1.InnerInvoke() 在 System.Threading.Tasks.Task.Execute() --- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 在 Example.Program.d__7.MoveNext() 位置 E:\test123\openair\example\Program.cs:行号 204 --- 内部异常堆栈跟踪的结尾 --- 在 System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) 在 System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) 在 System.Threading.Tasks.Task.Wait() 在 Example.Program.Main(String[] args) 位置 E:\test123\openair\example\Program.cs:行号 37

zhmi19811015 avatar Mar 28 '20 01:03 zhmi19811015

我未能重现出来,服务端传空值过来? 可能的话查看这地方是不是参数的数据长度为0

hzexe avatar Mar 17 '21 17:03 hzexe

CityCode=210200,CityName="大连市" 目前会触发这个问题;我正在尝试在上述提到的位置直接返回null

alonehat avatar Apr 07 '22 09:04 alonehat

CityCode=210200,CityName="大连市" 目前会触发这个问题;我正在尝试在上述提到的位置直接返回null

直接返回null还是会触发 “OpenRiaServices.DomainServices.Client.DomainOperationException”的未经处理的异常。我进行了如下的失败尝试:

1、在多个受影响位置,当 publishCtx.GetAirByCity(230600) HasError时,执行MarkErrorAsHandled(); 2、在Load时指定 throwOnError 为false以阻止异常 3、使用Task 的 WaitAll 和 WaitAny 并增加异步任务的异常处理

上述解决办法都无效,无法阻止该异常。

目前解决办法是:不再通过遍历站点的办法进行数据获取,而是直接调用获取省级所有站点数据(GetProvincePublishLives),然后通过逐层匹配,将站点具体信息获取到。目前暂未遇到任何问题。

alonehat avatar Apr 08 '22 01:04 alonehat