Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Unity with MRTK 2.8.3 & IL2CPP fails to Build in Visual Studio 2022

Discussion in 'AR' started by rensvv2703, Aug 1, 2023.

  1. rensvv2703

    rensvv2703

    Joined:
    Jul 3, 2023
    Posts:
    2
    I am trying to build my unity project so I can deploy it to the HoloLens 2. The project works fine in the editor and Unity also builds the project to a cpp solution. But when I try to build and deploy this to the hololens using VS2022 it fails.

    1>EXEC : error : Unity.IL2CPP.Building.BuilderFailedException: Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(6846): error C2664: 'Vector3_t24C512C7B96BBABAD472002D0BA2BDA40A5A80B2 SystemNumericsExtensions_ToUnityVector3_mBBDF1382455F9D34DBEBC4ABEF3724E1293F7254(Vector3_tCC8562BAFFDC06A7846FD7D7B13397E3E8041E3D,const RuntimeMethod *)': cannot convert argument 1 from 'Vector3_t0A314A276774EDB18C6BCC9A3C581AA7EE4F2F94' to 'Vector3_tCC8562BAFFDC06A7846FD7D7B13397E3E8041E3D'
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(6846): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(3596): note: see declaration of 'SystemNumericsExtensions_ToUnityVector3_mBBDF1382455F9D34DBEBC4ABEF3724E1293F7254'
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(6846): note: while trying to match the argument list '(Vector3_t0A314A276774EDB18C6BCC9A3C581AA7EE4F2F94, int)'
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(6852): error C2664: 'Vector3_t24C512C7B96BBABAD472002D0BA2BDA40A5A80B2 SystemNumericsExtensions_ToUnityVector3_mBBDF1382455F9D34DBEBC4ABEF3724E1293F7254(Vector3_tCC8562BAFFDC06A7846FD7D7B13397E3E8041E3D,const RuntimeMethod *)': cannot convert argument 1 from 'Vector3_t0A314A276774EDB18C6BCC9A3C581AA7EE4F2F94' to 'Vector3_tCC8562BAFFDC06A7846FD7D7B13397E3E8041E3D'
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(6852): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(3596): note: see declaration of 'SystemNumericsExtensions_ToUnityVector3_mBBDF1382455F9D34DBEBC4ABEF3724E1293F7254'
    1>C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp(6852): note: while trying to match the argument list '(Vector3_t0A314A276774EDB18C6BCC9A3C581AA7EE4F2F94, int)'
    1>
    1>Invocation was: Executable: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\ARM64\cl.exe"
    1>Arguments: "C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source\il2cppOutput\Microsoft.MixedReality.Toolkit.Providers.XRSDK.WindowsMixedReality.cpp" /nologo /c /bigobj /W3 /Z7 /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /wd4834 /wd4722 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /Yupch-cpp.hpp /Fp"C:\Users\user\Downloads\newbuild_kv2\build\obj\il2cppOutputProject\ARM64\Release\3CA478D8EF2AD12D54090C043DB63D38.pch" /MD -d2ssa-cfg-jt- /DWINDOWS_UWP /DUNITY_UWP /DUNITY_WSA_10_0 /DUNITY_WSA /DUNITY_WINRT /DPLATFORM_WINRT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /DIL2CPP_ENABLE_WRITE_BARRIERS=1 /DIL2CPP_INCREMENTAL_TIME_SLICE=3 /DBASELIB_INLINE_NAMESPACE=il2cpp_baselib /DIL2CPP_DEFAULT_DATA_DIR_PATH=Data/il2cpp_data /DBASELIB_USE_DYNAMICLIBRARY=1 /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=22621 /D__WRL_NO_DEFAULT_LIB__ /DWINAPI_FAMILY=WINAPI_FAMILY_APP /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\libil2cpp" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\libil2cpp" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\external\bdwgc\include" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\external\xxHash" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\external\baselib\Include" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\external\baselib\Platforms\UniversalWindows\Include" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\libil2cpp\pch" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\IL2CPP\libil2cpp\os\ClassLibraryPAL\brotli\include" /I"C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\Source" /I"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt" /Fo"C:\Users\user\Downloads\newbuild_kv2\build\obj\il2cppOutputProject\ARM64\Release\382007FC166801539B8C6AC37CDB1618.obj" /Fd"C:\Users\user\Downloads\newbuild_kv2\build\obj\il2cppOutputProject\ARM64\Release\382007FC166801539B8C6AC37CDB1618.pdb"
    1>EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64
    1>
    1> at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
    1> at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    1> at il2cpp.Compilation.CompilationDriver.Run(RuntimePlatform platform, Il2CppCommandLineArguments il2CppCommandLineArguments, BuildingOptions buildingOptions, ReadOnlyCollection`1 matchedAssemblyMethodSourceFiles)
    1> at il2cpp.Program.DoRun(String[] args, RuntimePlatform platform, Il2CppCommandLineArguments il2CppCommandLineArguments, BuildingOptions buildingOptions, Boolean throwExceptions)
    1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command ""C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\\IL2CPP\build\deploy\il2cpp.exe" --libil2cpp-static --compile-cpp -architecture=ARM64 -configuration=Release -platform=winrt -outputpath="C:\Users\user\Downloads\newbuild_kv2\\build\bin\ARM64\Release\GameAssembly.dll" --data-folder="C:\Users\user\Downloads\newbuild_kv2\\build\bin\ARM64\Release\\" -cachedirectory="C:\Users\user\Downloads\newbuild_kv2\\build\obj\il2cppOutputProject\ARM64\Release\\" -generatedcppdir="C:\Users\user\Downloads\newbuild_kv2\Il2CppOutputProject\\Source" --incremental-g-c-time-slice=3 --baselib-directory="C:\Program Files\Unity\Hub\Editor\2021.3.29f1\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\il2cpp\ARM64\Release" --avoid-dynamic-library-copy --dont-deploy-baselib --profiler-report --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT --additional-defines=PLATFORM_WINRT -dotnetprofile=unityaot-win32 -verbose --relative-data-path=Data/il2cpp_data --compiler-flags="-d2ssa-cfg-jt-"" exited with code 4.
    1>Done building project "Il2CppOutputProject.vcxproj" -- FAILED.

    Unfortunately I have no idea why. I updated unity, VS2022, all packages and MRTK to the latest version.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,755
    It looks like there might be two different definitions of the same Vector3 type in an assembly code in this project. Does the project use DLLs from NuGet (or some other source) which define the same types used in the .NET base class library? If so, removing those DLLS from the project might correct this issue.
     
  3. rensvv2703

    rensvv2703

    Joined:
    Jul 3, 2023
    Posts:
    2
    Hi Josh, thanks for your response. I have recently added two NuGet packages to my project, the "Azure.Identity" and the Azure.Security.KeyVault.Secrets" packages. I want to implement a Azure KeyVault in my project. I installed these packages with "NuGetForUnity" version 3.1.3.

    The two Microsoft packages included a lot of implicitly installed packages, mostly from the System namespace. Could the problem lie in one of those packages?

    The implicitly installed System packages are:

    System.Buffers,
    System.Diagnostics.DiagnosticSource,
    System.IO.FileSystem.AccessControl,
    System.Memory,
    System. Memory.Data,
    System.Numerics.Vectors (the issue probably lies here),
    System.Runtime.CompilerServices.Unsafe,
    System.Security.Cryptograhoy.ProtectedData,
    System.Security.Principal.Windows,
    System.Text.Encodings.Web,
    System.Text.Json,
    System.Threading.Tasks.Extensions

    Are these implicitly installed packages via the NuGetForUnity manager erroneous and therefore
    unnecessary?
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,755
    Yes, I suspect some of those assemblies are causing this. Try to remove System.Numerics.Vectors.dll, that might work around the issue. We've also seen similar issues with System.Memory.dll in the past.

    In general, if the NuGet package is built against .NET Standard 2.1, you should not need any of these System.* implementation assemblies. The base class library code Unity ships support all of the .NET Standard 2.1 API.
     
    andyb-unity likes this.