ArgumentException: Value does not fall within the expected range.System.Net.Sockets.Socket.SetSocketOption

Viewed 824

I am deploying a unity build into HoloLens I do not know why I am getting this error, it works fine on Unity editor but when deploying to HoloLens it throws the following error:

ArgumentException: Value does not fall within the expected range.

System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue)

This is my piece of code

 try {
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(apiURL);
                httpWebRequest.Method = "POST";
                httpWebRequest.ContentType = "application/json";
                using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()
))
                    streamWriter.Write("{ \"config\": { \"languageCode\" : \"en-US\" }, \"audio\" : { \"content\" : \"" + file64 + "\"}}");
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

After debugging I've determined this is the line that is throwing the error

httpWebRequest.GetRequestStream()

Please can anyone help!?!

1 Answers

Regarding the issue as Socket connect causes the ArgumentException: Value does not fall within the expected range. error. We have confirmed that this is a tracking Unity bug internally and should has pushed a fix. And there is already a discussion in Unity forum: https://forum.unity.com/threads/il2cpp-failing-in-windows-machine.891436/#post-5944052

You can try to verify the latest Unity 2019.4.x version to see if the fix has been merged or check the workaround in the above community discussion.

Related