Share via

Xamarin code Fails under release, doesnt during debug, UploadFile, gets fault

rick ruhl 61 Reputation points
2021-11-10T19:08:06.397+00:00

Visual Studio 2022, version 17.0.0
Xcode 13.1

The following code works in debug mode, but faults on release mode when uploadfile is hit.

 void CameraView_MediaCaptured(object sender, MediaCapturedEventArgs e)
        {

            Record.Text = "Re-Record";

            // shutterButton.Text = $"{++counter}";
            FileMediaSource file = e.Video.File;

            string folder = FileSystem.AppDataDirectory;

            string videomedia=file.ToString();
            videobase64 = videomedia;
            videobase64=videobase64.Replace("File: ", "");


        }

        async void OnSend(object sender, EventArgs e)
        {



            Constants.RestUrl = "https://collage.exteres.com/vwalk/procPIP.php";
            WebClient client = new WebClient();


            await Task.Run(() =>
            {
                byte[] byteResponse = client.UploadFile(Constants.RestUrl, videobase64);
                string resultString = System.Text.Encoding.UTF8.GetString(byteResponse, 0, byteResponse.Length);

                var result = JsonConvert.DeserializeObject(resultString);
                Console.WriteLine(string.Format("Upload completed: {0}", result));

                Send.Text = "Sent";
            });


        }

What could be causing it to fault under release mode only.

Developer technologies | .NET | Xamarin

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.