【发布时间】: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