I had an application working fine until about 2 days ago where a HoloLens 1 connected via TCP to another PC on a local network.
Recently, every call to TcpClient() default constructor throws the error above. No values are being passed into it (since it is default), therefore I have no idea what value it is erroring on.
I have tried the following solution, linked to me by someone on the HoloLens slack: https://github.com/Azure/azure-remote-rendering/issues/6
That solution entails updating to Unity 2019.3.15f. I've tried multiple different configurations of Visual Studio, Windows SDK, and Unity.
I have found multiple other posts which seem to indicate that the culprit is il2cpp. Here is a copy of the relevant output.
UnloadTime: 7.610200 ms
Exception thrown at 0x771E3AE2 in TCPTest.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x025CE7EC.
Exception thrown at 0x771E3AE2 in TCPTest.exe: Microsoft C++ exception: Il2CppExceptionWrapper at memory location 0x025CE90C.
ArgumentException: Value does not fall within the expected range.
at System.Net.Sockets.Socket.SetSocketOption (System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, System.Int32 optionValue) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket.set_DontFragment (System.Boolean value) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket.SocketDefaults () [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.TcpClient.initialize () [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.TcpClient..ctor (System.Net.Sockets.AddressFamily family) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.TcpClient..ctor () [0x00000] in <00000000000000000000000000000000>:0
at TcpTestClient.Start () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
The most minimal occurrence of this error I have so far produced is as follows:
New Unity project (doesn't seem to matter which version)
Add a GameObject to the scene, attach:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net.Sockets;
public class TcpTestClient : MonoBehaviour
{
private TcpClient tcpClient;
// Start is called before the first frame update
void Start()
{
tcpClient = new TcpClient();
if (tcpClient != null)
{
Debug.Log("Constructor succeeded!");
}
}
}
Configure Unity build settings as specified for HoloLens 1, making sure to include InternetClient, InternetClientServer, PrivateNetworkClientServer, in Publishing settings > Capabilities.
Build, open resulting solution in either Visual Studio 2017 or 2019 with appropriate build tools installed. Deploy to HoloLens and the resulting error will be output to the debug console.
Thanks for reading, I would really appreciate any insights anyone has.