IL2CPP Failing in Windows Machine

Hi there,

I have recently downgraded Visual Studio from 2019 back to 2017 which I was using for a long time with no issues. Now when I’m compiling for Windows x86-64 with IL2CPP .Net x4 I’m getting the following error:

One thing I noticed is that unity is still trying to use Windows Kit 10.0.19041.0 which was a part of the VS2019 install and is no longer there. Where is it getting this old version of WinSDK from even if that is the problem at all.

Help please :frowning:

Justin

1 Like

Likely when you uninstalled Visual Studio, it didn’t cleanup the registry and it’s still saying that SDK is installed. You can either install that SDK back (you can use it with VS2017) from Windows SDK - Windows app development | Microsoft Developer, or you can manually change the registry values to point to older SDK at “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0”.

6 Likes

Hey @Tautvydas-Zilys ,

You my friend are awesome. This fixed my issue and I’m able to continue building again. One thing to make a note of is that the new Win 10 SDK 10.0.19041.0 released on the 15th May 2020 has some issues with sockets in Unity. All my networking broke, reverting back to Win 10 SDK 10.0.17763.0 and all networking works again.

This new version is now installed automatically with VS2019 in case others get issues.

Justin

2 Likes

I had a similar problem caused by the latest Windows 10 SDK 10.0.19041.0 which is not fully compatible with unity il2cpp yet.
(async TcpClient socket connect causes an “ArgumentException: Value does not fall within the expected range.” while using it at least with NoDelay and specific timeout values.)
This is a general problem I have encountered before. I had the exact same problem some time ago with 10.0.18362.0 when it was first available.
Unity probably should have a way to select the Windows 10 SDK to use for il2cpp builds if multiple versions are available instead of always using the latest one.
The other issue that, even after uninstalling the newest Windows 10 SDK the above-mentioned registry key isn’t properly updated, technically is the fault of Microsoft but finger-pointing doesn’t really help anyone.
Being able to ourselves select the Windows SDK to use is all we would need to get around these kinds of obscure issues which can be incredibly frustrating to debug.

1 Like

Can you report a bug on this?

tracker id: 1249143
Please tell me if you didn’t mean that.

1 Like

This was exactly the same error I was having which is what led to us rolling back to a previous Win 10 SDK version.

Justin

1 Like

I had this issue too. 9xxx SDK breaks IL2CPP sockets. Socket ctor throws "ArgumentException: Value does not fall within the expected range"

UWP build has a drowdown for selecting SDK versjon. Seems like an error that desktop windows does not.

We have a fix for this coming, all the way back to Unity 2018.4. If you want to work around sooner, here’s the source code patch (you can find it at Editor\Data\il2cpp):

diff --git a/libil2cpp/os/Win32/SocketImpl.cpp b/libil2cpp/os/Win32/SocketImpl.cpp
index f63abecd5..5821d2577 100644
--- a/libil2cpp/os/Win32/SocketImpl.cpp
+++ b/libil2cpp/os/Win32/SocketImpl.cpp
@@ -1700,11 +1700,7 @@ namespace os
                 break;

             case kSocketOptionLevelIP:
-#ifdef SOL_IP
-                *system_level = SOL_IP;
-#else
                 *system_level = IPPROTO_IP;
-#endif

                 switch (name)
                 {
@@ -1777,11 +1773,7 @@ namespace os
                 break;
 #if IL2CPP_SUPPORT_IPV6
             case kSocketOptionLevelIPv6:
-        #ifdef SOL_IPV6
-                *system_level = SOL_IPV6;
-        #else
                 *system_level = IPPROTO_IPV6;
-        #endif

                 switch (name)
                 {
2 Likes

Is there an ETA on when this patch will come out? Will it be pushed to Unity 2019.x?

Yeah it going to both 2019.4 and 2018.4. The backport is on the way but I don’t have any concrete dates to share.

1 Like

Thank you for the response, does this mean it’s live in 2019.4 currently?

No, it’s not. It will be in a future 2019.4.x release.

1 Like

Is it in 2019.4.3f1?

I have just upgraded to 2019.4.3f1 because I ran into the above problem when building for HoloLens 2. Unfortunately the fix seems not to be included in this version yet.

However, I was able to manually patch the file “Win32/SocketImpl.cpp” by removing the SOL_IP references and got it working!

@BenjaminBachman
I’m running into the same issue, what did you change here to make this happen? can you post your code?

Go to “Installs”, click on the 3 dots:
6090762--661542--upload_2020-7-14_23-24-5.png

Select “Show in Explorer”:

6090762--661545--upload_2020-7-14_23-24-32.png

You should arrive in something like “C:\Program Files\Unity\Hub\Editor\2019.4.3f1\Editor”
Go to the sub-folder “…\Data\il2cpp\libil2cpp\os\Win32” and open the file “SocketImpl.cpp” in an editor of your choice.

then go to around line 1700 and delete the lines reading

  • #ifdef SOL_IP
  • *system_level = SOL_IP;
  • #else
  • #endif

The line reading “*system_level = IPPROTO_IP;” should remain.
Go to line 1777 and do the same there.

Restart Unity, rebuild your project. Maybe you have to delete the build folder first.

when I try this i get the following error

Guess i’ll have to wait for the official fix.

That is not a crash. Uncheck “Break when this exception type is thrown” and it will go away.

Just tested this in 2020.1.0f1 and it seems it has still not been fixed yet.