[Solved] UWP crash when initializing Unity IAP

Hello,

we have a crash in our UWP build caused by the following exception when intiializing Unity IAP (.NET backend):

[External Code]
System.Private.SharedLibrary.Interop.Generated.dll!McgInterop.api_ms_win_core_kernel32_legacy_l1_1_0_dll.PInvoke_RaiseFailFastException(Interop._EXCEPTION_RECORD* pExceptionRecord, Interop._CONTEXT* pContextRecord, uint dwFlags) Line 1960    C#
System.Private.CoreLib.dll!Interop.mincore.PInvoke_RaiseFailFastException(Interop._EXCEPTION_RECORD* pExceptionRecord, Interop._CONTEXT* pContextRecord, uint dwFlags)    C#
System.Private.CoreLib.dll!Interop.mincore.RaiseFailFastException(uint faultCode, System.IntPtr pExContext) Line 764    C#
System.Private.CoreLib.dll!System.RuntimeExceptionHelpers.FailFast(string message, System.Exception exception, System.RuntimeExceptionHelpers.RhFailFastReason reason, System.IntPtr pExContext) Line 226    C#
System.Private.CoreLib.dll!System.RuntimeExceptionHelpers.RuntimeFailFast(System.RuntimeExceptionHelpers.RhFailFastReason reason, System.Exception exception, System.IntPtr pExContext) Line 186    C#
[External Code]
System.Private.CoreLib.dll!System.Runtime.InteropServices.GCHandle.FromIntPtr(System.IntPtr value) Line 207    C#
UnityEngine.dll!UnityEngine.Internal.$MethodUtility.CreateInstanceAndInvokeDefaultConstructor(System.IntPtr type, System.UIntPtr argument0, long* argument1)    C#
WinRTBridge.dll!WinRTBridge.MethodTools.CreateInstanceAndInvokeDefaultConstructorDelegate.InvokeOpenStaticThunk(System.IntPtr managedHandle, System.UIntPtr argument, long* exception)    C#
WinRTBridge.dll!WinRTBridge.MethodTools.CreateInstanceAndInvokeDefaultConstructorDelegate.Invoke(System.IntPtr managedHandle, System.UIntPtr argument, long* exception)    C#
>    War to the Core.McgInterop.dll!WinRTBridge.MethodTools_CreateInstanceAndInvokeDefaultConstructorDelegate__WinRTBridge__Impl.ReverseDelegateStub(System.IntPtr unsafe_managedHandle, System.UIntPtr unsafe_argument, long* unsafe_exception) Line 153832    C#
[External Code]
War to the Core.McgInterop.dll!McgInterop.UnityEngineDelegates_dll.GameObject_CUSTOM_Internal_AddComponentWithType(System.IntPtr param_0, int param_1) Line 14394    C#
UnityEngineProxy.dll!UnityEngineProxy.InternalCalls.PInvokeCalls.GameObject_CUSTOM_Internal_AddComponentWithType(System.IntPtr param_0, int param_1)    C#
UnityEngineProxy.dll!UnityEngineProxy.InternalCalls.GameObject_CUSTOM_Internal_AddComponentWithType(object self, System.Type componentType) Line 19515    C#
[External Code]
UnityEngine.dll!UnityEngine.GameObject.AddComponent(System.Type componentType) Line 381    C#
UnityEngine.dll!UnityEngine.GameObject.AddComponent<UnityEngine.Purchasing.Extension.UnityUtil>() Line 386    C#
[External Code]
Assembly-CSharp.dll!IAP.InitializePurchasing() Line 32    C#
Assembly-CSharp.dll!IAP.Start() Line 23    C#
[External Code]

This is the code triggering it:

var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.Configure<IMicrosoftConfiguration>().useMockBillingSystem = true;

builder.AddProduct("my_product_id", ProductType.Consumable);

UnityPurchasing.Initialize(this, builder);

Thank you

Hi @ung ,

Would you be able to provide some more information about this issue?

What device and OS version do you see this issue on?
Are you able to reproduce this issue with a new project and your IAP implementation?

If you could provide that information, we would be able to provide further assistance.

Hi @ap-unity

Fortunately we solved the issue. It was an error on our side, we had a modified C# project that wasn’t referencing all the required dlls.

Thank you very much for your interest

1 Like