当前位置: 代码迷 >> 综合 >> 在Hololens中开发TCP通信,错误“ArgumentException: Value does not fall within the expected range”的解决方案
  详细解决方案

在Hololens中开发TCP通信,错误“ArgumentException: Value does not fall within the expected range”的解决方案

热度:88   发布时间:2024-02-05 03:40:38.0

在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.0Unity2019.3.15fSocket之间存在一些问题导致的。

解决方法

????据说在新发布的Unity中已经解决了这个问题,博主更新到最新版Unity之后发现虽然没有了这个错误,但项目直接无法运行了,最终通过如下方式解决:

  1. 在UnityHub中找到Unity2019.3.15f,选择在资源管理器中显示(如果自己记得Unity的安装位置可以直接打开安装位置):
    在这里插入图片描述
  2. 打开文件夹 …\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

  相关解决方案