【问题标题】:ArgumentException: Value does not fall within the expected range.System.Net.Sockets.Socket.SetSocketOptionArgumentException:值不在预期范围内。System.Net.Sockets.Socket.SetSocketOption
【发布时间】:2020-07-10 16:55:30
【问题描述】:

我正在将统一构建部署到 HoloLens 我不知道为什么会收到此错误,它在 Unity 编辑器上运行良好,但在部署到 HoloLens 时会引发以下错误:

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)

这是我的一段代码

 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();

调试后我确定这是引发错误的行

httpWebRequest.GetRequestStream()

请任何人帮忙!?!

【问题讨论】:

  • 您能否在“发布设置”>“功能”中仔细检查以下功能:InternetClient、InternetClientServer、PrivateNetworkClientServer。因为根据你的报错信息,好像是你的应用没有成功连接到服务器。
  • 此外,我们发现这个帖子指出Windows SDK版本不匹配也可能导致此问题:stackoverflow.com/questions/62314810/…因此,值得尝试将Build Settings > Target SDK version设置为10.0.17763.0 .

标签: c# sockets unity3d hololens


【解决方案1】:

将问题视为 Socket 连接会导致 ArgumentException: Value does not fall within the expected range. 错误。我们已经确认这是一个内部跟踪 Unity 错误,应该已经推送了修复程序。 Unity论坛里已经有讨论:https://forum.unity.com/threads/il2cpp-failing-in-windows-machine.891436/#post-5944052

您可以尝试验证最新的 Unity 2019.4.x 版本以查看修复是否已合并或查看上述社区讨论中的解决方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-12
    • 1970-01-01
    • 1970-01-01
    • 2011-08-09
    • 1970-01-01
    相关资源
    最近更新 更多