I have encountered an issue while trying to connect a managed debugger to a UWP IL2CPP build. The build is not visible when trying to connect through Debug → Attach Unity Debugger.
The setup is like this: Managed debugging with Unity - Mixed Reality | Microsoft Learn
With the difference that the build is installed locally through Windows Device Portal.
My Visual Studio version is Professional 2017 (15.9.17). Unity tools are installed and I can connect the debugger for other platforms just fine.
Unity version is 2019.2.12f.
Are there any steps or configuration I could have missed?
Make sure the internet server and private networks capabilities are enabled in the app manifest.
Is this debugging on local or remote machine?
The capabilities are enabled.
I am debugging on local machine. Does the configuration need to be set as remote when the build is installed through Windows Device Portal? If so then what configuration should I be using for the remote debugger?
No, you don’t need to change remote debugger configuration at all.
Which build (debug/release/master) do you have deployed via the device portal? Can you attach AppxManifest.xml that is located next to the executable that runs when you run the app? You can find the location of the executable through task manager.
The build is a debug build. The AppxManifest.xml looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
Game
Publisher
Assets\StoreLogo.png
Microsoft.Xbox.Services.dll
UnityPlayer.dll
I think I know what’s happening… For the debugger to be able to multicast to Visual Studio on local machine, the app must be granted loopback limitations exemption (see this: c# - UWP Enable local network loopback - Stack Overflow ). When you run via Visual Studio OR Build & Run in Unity, it is done for you, but I guess device portal doesn’t do it.
I tried granting the loopback limitations exemption, however it didn’t work. I also did notice that when checking the package details through “CheckNetIsolation LoopbackExempt -s” it says “IsDevelopementMode : false”. Can this be an indication of an issue? The build configuration is set to debug in VS and it is a development build in Unity.
I tried both setting the debugger to local machine and remote but I couldn’t connect to the build with either of them.
Does the debugger work if you deploy it via Build & Run OR via Visual Studio?
If I run the build through the generated Visual Studio project, it does attach its debugger, however the project is in C++ due to the IL2CPP backend. I cannot connect the C# project I use for scripting through the Attach Unity Debugger command.
The Build And Run command generates the project, but it fails to automatically build it through Unity with the following error (I have to manually open and build it):
BuildFailedException: Failed to build Visual Studio project using arguments ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe “S:\Projects\Builds\Test\Test Build.sln” /nologo /maxcpucount /p:Configuration=Debug /p:platform=x64 /p:SolutionDir=“S:\Projects\Builds\Test\” /t:Build /clp:Verbosity=minimal’.
Output: Building GameAssembly.dll with MsvcWinRtToolChain
Msvc Install Version: 15.0
Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe
Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe
Output directory: S:\Projects\Builds\Test\build\bin\x64\Debug
Cache directory: S:\Projects\Builds\Test\build\obj\il2cppOutputProject\x64\Debug
Il2CppMetadataUsage.c
Assembly-CSharp_Debugger.c
Il2CppTypeDefinitions.c
Il2CppAttributes.cpp
Il2CppGenericMethodDefinitions.c
Il2CppGenericClassTable.c
Il2CppGenericMethodTable.c
Il2CppGenericMethodPointerTable.cpp
Il2CppInteropDataTable.cpp
Il2CppCompilerCalculateTypeValues2.cpp
Il2CppInvokerTable.cpp
Il2CppCompilerCalculateTypeValues3.cpp
Assembly-CSharp-firstpass_Debugger.c
Il2CppCompilerCalculateTypeValues4.cpp
Assembly-CSharp_CodeGen.c
Il2CppCompilerCalculateTypeValues.cpp
Il2CppCompilerCalculateTypeValues1.cpp
Rewired_Core_Debugger.c
Rewired_Core_CodeGen.c
mscorlib_CodeGen.c
com.unity.multiplayer-hlapi.Runtime_Debugger.c
GenericMethods2.cpp
Assembly-CSharp10.cpp
System.Xml3.cpp
mscorlib_Debugger.c
Assembly-CSharp33.cpp
UnityEngine.UI_Debugger.c
Il2CppGenericInstDefinitions.c
Assembly-CSharp17.cpp
Assembly-CSharp24.cpp
Rewired_Core12.cpp
Assembly-CSharp18.cpp
Rewired_Core3.cpp
Assembly-CSharp13.cpp
Il2CppComCallableWrappers2.cpp
Assembly-CSharp26.cpp
Rewired_Core13.cpp
Rewired_Core.cpp
Rewired_Core10.cpp
Assembly-CSharp28.cpp
Assembly-CSharp38.cpp
Assembly-CSharp19.cpp
System.Xml12.cpp
GenericMethods10.cpp
System.Xml6.cpp
Rewired_Core19.cpp
Assembly-CSharp25.cpp
Assembly-CSharp27.cpp
Rewired_Core11.cpp
Assembly-CSharp15.cpp
Assembly-CSharp46.cpp
GenericMethods7.cpp
System.Xml4.cpp
Assembly-CSharp14.cpp
Rewired_Core1.cpp
GenericMethods11.cpp
mscorlib6.cpp
Assembly-CSharp48.cpp
mscorlib21.cpp
Assembly-CSharp29.cpp
Assembly-CSharp20.cpp
Assembly-CSharp16.cpp
Assembly-CSharp34.cpp
Il2CppComCallableWrappers3.cpp
Assembly-CSharp37.cpp
Assembly-CSharp36.cpp
System.Xml1.cpp
Assembly-CSharp8.cpp
UnityEngine.CoreModule_Debugger.c
Assembly-CSharp45.cpp
Assembly-CSharp9.cpp
System5.cpp
Generics8.cpp
Assembly-CSharp30.cpp
Rewired_Core16.cpp
Assembly-CSharp49.cpp
Generics60.cpp
Assembly-CSharp50.cpp
System.Xml8.cpp
Rewired_Core15.cpp
GenericMethods6.cpp
System3.cpp
Assembly-CSharp51.cpp
Assembly-CSharp47.cpp
mscorlib5.cpp
GenericMethods1.cpp
Assembly-CSharp12.cpp
Assembly-CSharp4.cpp
System.Xml10.cpp
Generics7.cpp
mscorlib14.cpp
com.unity.multiplayer-hlapi.Runtime4.cpp
Rewired_Core2.cpp
System.Xml11.cpp
Assembly-CSharp41.cpp
Assembly-CSharp31.cpp
System4.cpp
Assembly-CSharp.cpp
mscorlib15.cpp
Generics15.cpp
Generics6.cpp
Assembly-CSharp-firstpass.cpp
Rewired_Core6.cpp
Rewired_Core4.cpp
UnityEngine.UI1.cpp
Assembly-CSharp35.cpp
Rewired_Core14.cpp
Generics59.cpp
System.Xml9.cpp
System1.cpp
Assembly-CSharp21.cpp
System.cpp
Il2CppComCallableWrappers1.cpp
mscorlib3.cpp
Assembly-CSharp43.cpp
Rewired_Core5.cpp
System.Xml7.cpp
System2.cpp
mscorlib12.cpp
Assembly-CSharp22.cpp
Assembly-CSharp23.cpp
mscorlib16.cpp
mscorlib13.cpp
Generics30.cpp
Assembly-CSharp32.cpp
Rewired_Core18.cpp
mscorlib8.cpp
Il2CppCompilerCalculateTypeValues5.cpp
Il2CppComCallableWrappers39.cpp
UnityEngine.UI2.cpp
System.Xml5.cpp
Assembly-CSharp-firstpass2.cpp
System.Xml.cpp
Assembly-CSharp39.cpp
mscorlib18.cpp
com.unity.multiplayer-hlapi.Runtime3.cpp
mscorlib2.cpp
Il2CppComCallableWrappers4.cpp
GenericMethods9.cpp
System.Xml2.cpp
mscorlib9.cpp
Generics16.cpp
Assembly-CSharp7.cpp
Generics.cpp
Rewired_Core9.cpp
Generics14.cpp
Generics17.cpp
Assembly-CSharp42.cpp
Rewired_Core8.cpp
Assembly-CSharp11.cpp
GenericMethods8.cpp
mscorlib.cpp
Rewired_Core17.cpp
Generics68.cpp
Generics29.cpp
com.unity.multiplayer-hlapi.Runtime.cpp
mscorlib20.cpp
mscorlib1.cpp
Assembly-CSharp44.cpp
Assembly-CSharp-firstpass3.cpp
Generics37.cpp
Assembly-CSharp-firstpass4.cpp
UnresolvedVirtualCallStubs.cpp
Generics5.cpp
mscorlib7.cpp
Il2CppComCallableWrappers.cpp
Generics67.cpp
Assembly-CSharp-firstpass9.cpp
mscorlib10.cpp
GenericMethods5.cpp
Assembly-CSharp-firstpass7.cpp
UnityEngine.UI4.cpp
Generics62.cpp
Generics39.cpp
mscorlib4.cpp
Generics51.cpp
Generics4.cpp
Il2CppComCallableWrappers19.cpp
mscorlib19.cpp
Rewired_Core7.cpp
Il2CppComCallableWrappers14.cpp
Il2CppComCallableWrappers30.cpp
Generics50.cpp
Assembly-CSharp1.cpp
Il2CppComCallableWrappers8.cpp
GenericMethods4.cpp
Il2CppComCallableWrappers27.cpp
UnityEngine.CoreModule3.cpp
Il2CppComCallableWrappers17.cpp
Il2CppComCallableWrappers29.cpp
Il2CppComCallableWrappers42.cpp
Il2CppComCallableWrappers35.cpp
UnityEngine.CoreModule1.cpp
Il2CppComCallableWrappers31.cpp
Il2CppComCallableWrappers33.cpp
Il2CppComCallableWrappers9.cpp
Generics61.cpp
Unity.Timeline.cpp
UnityEngine.UI3.cpp
com.unity.multiplayer-hlapi.Runtime5.cpp
Il2CppComCallableWrappers13.cpp
UnityEngine.UI.cpp
Il2CppComCallableWrappers26.cpp
Il2CppComCallableWrappers15.cpp
Assembly-CSharp-firstpass5.cpp
Il2CppComCallableWrappers18.cpp
Il2CppComCallableWrappers34.cpp
Il2CppComCallableWrappers21.cpp
Assembly-CSharp6.cpp
Assembly-CSharp-firstpass8.cpp
mscorlib11.cpp
Il2CppComCallableWrappers16.cpp
Il2CppComCallableWrappers41.cpp
Il2CppComCallableWrappers51.cpp
Il2CppComCallableWrappers25.cpp
Il2CppComCallableWrappers24.cpp
Il2CppComCallableWrappers53.cpp
UnityEngine.UI5.cpp
Generics46.cpp
Il2CppComCallableWrappers28.cpp
Il2CppComCallableWrappers43.cpp
Il2CppComCallableWrappers10.cpp
Il2CppComCallableWrappers50.cpp
System.Xml_CodeGen.c
Generics38.cpp
Assembly-CSharp-firstpass10.cpp
Assembly-CSharp5.cpp
Il2CppComCallableWrappers54.cpp
Assembly-CSharp40.cpp
com.unity.multiplayer-hlapi.Runtime2.cpp
com.unity.multiplayer-hlapi.Runtime1.cpp
UnityEngine.UNETModule.cpp
Il2CppComCallableWrappers32.cpp
Il2CppComCallableWrappers6.cpp
Generics49.cpp
Il2CppComCallableWrappers20.cpp
Generics72.cpp
Il2CppComCallableWrappers23.cpp
Mono.Security.cpp
Il2CppComCallableWrappers48.cpp
Il2CppComCallableWrappers40.cpp
mscorlib17.cpp
Il2CppComCallableWrappers22.cpp
Il2CppComCallableWrappers47.cpp
Il2CppComCallableWrappers38.cpp
UnityEngine.CoreModule2.cpp
Il2CppComCallableWrappers44.cpp
UnityEngine.CoreModule.cpp
Il2CppComCallableWrappers49.cpp
Generics55.cpp
Il2CppComCallableWrappers52.cpp
Il2CppComCallableWrappers37.cpp
Il2CppComCallableWrappers46.cpp
Assembly-CSharp3.cpp
Assembly-CSharp2.cpp
Il2CppComCallableWrappers36.cpp
UnityEngine.IMGUIModule1.cpp
mscorlib22.cpp
Assembly-CSharp-firstpass1.cpp
Il2CppComCallableWrappers12.cpp
Generics69.cpp
Il2CppComCallableWrappers45.cpp
Generics74.cpp
Il2CppComCallableWrappers7.cpp
Generics3.cpp
Generics63.cpp
Generics19.cpp
Generics28.cpp
Generics1.cpp
Generics18.cpp
Generics53.cpp
Rewired_Core20.cpp
Generics75.cpp
Generics45.cpp
Generics52.cpp
Generics64.cpp
Generics2.cpp
Generics66.cpp
Generics71.cpp
Generics43.cpp
UnityEngine.IMGUIModule.cpp
Generics65.cpp
Generics22.cpp
Generics40.cpp
Generics57.cpp
Generics70.cpp
Il2CppComCallableWrappers11.cpp
Il2CppComCallableWrappers5.cpp
Generics56.cpp
Il2CppProjectedComCallableWrapperMethods4.cpp
GenericMethods.cpp
Il2CppCompilerCalculateTypeValuesTable.cpp
Generics54.cpp
Generics73.cpp
Generics58.cpp
Il2CppProjectedComCallableWrapperMethods.cpp
Generics44.cpp
Generics26.cpp
Generics20.cpp
Il2CppProjectedComCallableWrapperMethods2.cpp
GenericMethods3.cpp
Generics13.cpp
System.Xml_Debugger.c
Il2CppProjectedComCallableWrapperMethods1.cpp
Generics9.cpp
Assembly-CSharp-firstpass6.cpp
Il2CppProjectedComCallableWrapperMethods3.cpp
Generics21.cpp
Generics31.cpp
Generics48.cpp
Generics23.cpp
Generics27.cpp
Unity.Timeline1.cpp
Generics24.cpp
Generics32.cpp
Generics25.cpp
Generics33.cpp
Generics42.cpp
Generics35.cpp
Generics34.cpp
Generics12.cpp
Generics10.cpp
Generics36.cpp
UnityEngine.IMGUIModule_Debugger.c
Generics41.cpp
Generics47.cpp
Generics11.cpp
I18N.Rare.cpp
UnityEngine.CoreModule4.cpp
Generics76.cpp
GenericMethods12.cpp
Il2CppProjectedComCallableWrapperMethods5.cpp
com.unity.multiplayer-hlapi.Runtime6.cpp
UnityEngine.AndroidJNIModule.cpp
System_CodeGen.c
UnityEngine.AnimationModule.cpp
Unity.Timeline_Debugger.c
Il2CppGenericComDefinitions.cpp
Assembly-CSharp-firstpass_CodeGen.c
UnityEngine.VRModule.cpp
UnityEngine.IMGUIModule2.cpp
System_Debugger.c
UnityEngine.UnityWebRequestModule.cpp
UnityEngine.CoreModule_CodeGen.c
Il2CppComCallableWrappers55.cpp
UnityEngine.XRModule.cpp
Assembly-CSharp52.cpp
I18N.CJK.cpp
I18N.cpp
I18N.West.cpp
UnityEngine.Physics2DModule.cpp
I18N.Rare1.cpp
WindowsRuntimeMetadata.cpp
System.Core.cpp
UnityEngine.UI_CodeGen.c
UnityEngine.UNETModule_Debugger.c
com.unity.multiplayer-hlapi.Runtime_CodeGen.c
Assembly-CSharp-firstpass11.cpp
UnityEngine.ParticleSystemModule.cpp
char-conversions.cpp
System6.cpp
Mono.Security1.cpp
UnityEngine.TerrainModule.cpp
UnityEngine.AndroidJNIModule_Debugger.c
UnityEngine.PhysicsModule.cpp
I18N.Other.cpp
debugger-agent.c
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(638): warning C4005: ‘DEBUG’: macro redefinition [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c: note: see previous definition of ‘DEBUG’
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1071): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1072): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1073): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1073): warning C4028: formal parameter 2 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1074): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1074): warning C4028: formal parameter 2 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1075): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1075): warning C4028: formal parameter 2 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1076): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1077): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1078): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1078): warning C4028: formal parameter 2 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1082): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1082): warning C4028: formal parameter 2 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1083): warning C4028: formal parameter 1 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1083): warning C4028: formal parameter 2 different from declaration [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1320): warning C4244: ‘=’: conversion from ‘SOCKET’ to ‘int’, possible loss of data [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1396): warning C4244: ‘=’: conversion from ‘SOCKET’ to ‘int’, possible loss of data [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1428): warning C4244: ‘=’: conversion from ‘SOCKET’ to ‘int’, possible loss of data [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1432): warning C4133: ‘function’: incompatible types - from ‘int *’ to ‘const char *’ [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1488): warning C4244: ‘=’: conversion from ‘SOCKET’ to ‘int’, possible loss of data [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1710): warning C4267: ‘function’: conversion from ‘size_t’ to ‘int’, possible loss of data [S:\Projects\Builds\Test\Il2CppOutputProject\Il2CppOutputProject.vcxproj]
S:\Projects\Builds\Test\Il2CppOutputProject\IL2CPP\external\mono\mono\mini\debugger-agent.c(1716): warning C4267: ‘function’: conversion from ‘size_t’ to ‘int’, possible loss of data [S:\Projects<message truncated>
The build & run log is truncated I can’t see the error.
Anyway, this is so bizarre… it’s almost as if something is blocking the debugger connection. Are you able to test debugging on a remote machine?
Could you perhaps try enabling “inbound connection loopback exempt” using “CheckNetIsolation.exe LoopbackExempt -is -n=<PACKAGE_NAME>” (Communicating with Localhost - Windows IoT | Microsoft Learn ) and see if you can connect to the application via IP (127.0.0.1 if running on local machine) and port (that can be found in the player log)?
Lastly… just to make sure this wasn’t missed: do you have this checkbox checked when building from Unity?
1 Like
Yes! enabling the “inbound connection loopback exempt” worked. While I have this running I can make a connection through the local IP. Thanks for your help!