Skip to content

'System.ObjectDisposedException' on awaiting a API method #709

@hRupanjan

Description

@hRupanjan

Describe the bug

I got this Exception

  at System.IO.MemoryStream.CopyToAsync (System.IO.Stream destination, System.Int32 bufferSize, System.Threading.CancellationToken cancellationToken) [0x00042] in <3a61d48d66dd458fa0b64990b6c8f8cc>:0 
  at Xamarin.Android.Net.AndroidClientHandler.WriteRequestContentToOutput (System.Net.Http.HttpRequestMessage request, Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken) [0x0009a] in <ff9f3f3d4e134974a889db1b532c9b6e>:0 
  at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.URL javaUrl, Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken, Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState) [0x002f4] in <ff9f3f3d4e134974a889db1b532c9b6e>:0 
  at Xamarin.Android.Net.AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x002be] in <ff9f3f3d4e134974a889db1b532c9b6e>:0 
  at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x000ca] in <162fad71ed6e4a3cb7598d196d170e1b>:0 
  at Refit.RequestBuilderImplementation+<>c__DisplayClass14_0``2[T,TBody].<BuildCancellableTaskFuncForMethod>b__0 (System.Net.Http.HttpClient client, System.Threading.CancellationToken ct, System.Object[] paramList) [0x00188] in <7208242e8171474ea12db9d506d0c43f>:0 
  at Ser.WebAPIs.LoginApiService.Login (Ser.Models.MobileLoginParam loginCredential) [0x00035] in C:\Ser\Ser\Ser\WebAPIs\LoginApiService.cs:36 }

while executing this

public async Task<CWebResponse> Login(MobileLoginParam loginCredential)
        {
            CWebResponse response = null;
            try
            {
                response = await loginApi.Login(JsonConvert.SerializeObject(loginCredential));
            }
            catch (ApiException ex)
            {
                response = new CWebResponse { StatusCode = (CStatusCodes)ex.StatusCode, ErrorMessage = ex.Message };
            }
            catch (Exception e)
            {
                response = null;
            }
            return response;
}

This 'Login' method was awaited if you want more info. I'm getting this error repeatedly.

Environment

  • OS: Android
  • Version: 9 (Pie)
  • Device: Redmi Note 5 Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions