在Hololens中开发TCP通信,错误“ArgumentException: Value does not fall within the expected range”的解决方案
- 问题描述
- 解决方法
- 参考链接
问题描述
????在将异步TCP通信项目部署到Hololens2中运行时,出现错误“ArgumentException: Value does not fall within the expected range”,这是在5月15日发部的Win 10 SDK 10.0.19041.0与Unity2019.3.15f的Socket之间存在一些问题导致的。
解决方法
????据说在新发布的Unity中已经解决了这个问题,博主更新到最新版Unity之后发现虽然没有了这个错误,但项目直接无法运行了,最终通过如下方式解决:
- 在UnityHub中找到Unity2019.3.15f,选择在资源管理器中显示(如果自己记得Unity的安装位置可以直接打开安装位置):
- 打开文件夹 …\Editor\Data\il2cpp\libil2cpp\os\Win32找到文件SocketImpl.cpp,对文件做如下更改(代码块中前面带-号的均是需要删除的行):
在文件第1700行:
case kSocketOptionLevelIP:
-#ifdef SOL_IP
- *system_level = SOL_IP;
-#else*system_level = IPPROTO_IP;
-#endif
在第1773行:
#if IL2CPP_SUPPORT_IPV6case kSocketOptionLevelIPv6:
- #ifdef SOL_IPV6
- *system_level = SOL_IPV6;
- #else*system_level = IPPROTO_IPV6;
- #endif
如果不想自己修改或者害怕出错,博主将修改后的文件已传至资源https://download.csdn.net/download/qq_41452267/12678968
参考链接
On a HoloLens 1, when creating TcpClient object with default constructor “ArgumentException: Value does not fall within the expected range” is thrown
IL2CPP Failing in Windows Machine