我无法从xamarin ios单视图应用程序向服务器ASP .NET发送大量数据(内置字节数组的json) .

我的模型(在ios应用程序和服务器上相同)

public class VirtualTourDataModel
{
    public string VTName { get; set; }
    public List<ViewPoint> ViewPoints { get; set; }
}

public class ViewPoint
{
    public string PointName { get; set; }
    public byte[] Video { get; set; }
    public List<bool> Connections { get; set; }
}

我如何设置bytearray:

ViewPoint viewPoint = new ViewPoint();
                viewPoint.Video = ToByteArray(NSData.FromUrl(outputFileUrl));
                VirtualTourData.ViewPoints.Add(viewPoint);


        public static byte[] ToByteArray(NSData data)
        {
            var bytes = new byte[data.Length];
            System.Runtime.InteropServices.Marshal.Copy(data.Bytes, bytes, 0, Convert.ToInt32(data.Length));
            return bytes;
        }

我如何发送数据:

VirtualTourDataModel vtModel = new VirtualTourDataModel();
            vtModel.VTName = VirtualTourData.VTName;
            vtModel.ViewPoints = VirtualTourData.ViewPoints;               
            var json = JsonConvert.SerializeObject(vtModel);

            string sUrl = "http://192.168.0.56:6240/api/UploadVT/Upload";

    try
            {
                using (var httpClient = new HttpClient())
                {
                    httpClient.Timeout = TimeSpan.FromMinutes(1);
                    httpClient.BaseAddress = new Uri("http://192.168.0.56:6240");


                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    var url = new Uri(string.Concat("http://192.168.0.56:6240", "/api/UploadVT/Upload"));
                    HttpResponseMessage response = await httpClient.PostAsync(url, content);
                    if (response.IsSuccessStatusCode)
                    {
                        // this result string should be something like: "{"token":"rgh2ghgdsfds"}"
                        var result = await response.Content.ReadAsStringAsync();
                    }
                }                        
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

我在catch中收到此错误:

{System.ObjectDisposedException:无法访问已处置的对象 . 对象名称:'System.Net.Sockets.NetworkStream' . 在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/System/System.Net/WebConnectionStream中的System.Net.WebConnectionStream.EndWrite(System.IAsyncResult r)[0x000b9] .cs:617 at System.IO.Stream <> c.b__53_1(System.IO.Stream stream,System.IAsyncResult asyncResult)[0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src /mono/mcs/class/referencesource/mscorlib/system/io/stream.cs:729 at System.Threading.Tasks.TaskFactory 1+FromAsyncTrimPromise 1 [TResult,TInstance] .Complete(TInstance thisRef,System.Func 3[T1,T2,TResult] endMethod, System.IAsyncResult asyncResult, System.Boolean requiresSynchronization) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs:1441 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:447 at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x00324] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:379 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1 ConfiguredTaskAwaiter [TResult] .GetResult()[0x00000] in:0 in System.Net.Http.HttpClient d __8.MoveNext()[0x00080] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/ class / System.Net.Http / System.Net.Http / HttpClient.cs:276 ---抛出异常的前一个位置的堆栈跟踪结束---在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c在/Library/Frameworks/Xamarin.iOS中 . framework / Versions / 11.2.0.11 / src / mono / mcs / class / referencesource / mscorlib / system / runtime / exceptionservices / exceptionservicescommon.cs:151 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task task) )[0x00037]在System.Runtime的/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187中 . / Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/中的CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028]在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/中的System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008]中的runtime / compilerservices / TaskAwaiter.cs:156 System.Runtime.CompilerServices.Task中的src / mono / mcs / class / referencesource / mscorlib / system / runtime / compilerservices / TaskAwaiter.cs:128 Awaiter`1 [TResult] .GetResult()[0x00000] in:0在EasyVTApp.VTLinkViewController d _2.MoveNext()[0x00107]在D:\ magistr \ EasyVTApp \ EasyVTApp \ VTLinkViewController.cs:79}