From fcab7cd90367a2728beeb8ac19caaa747a12f8ac Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 27 Sep 2024 21:39:05 +1000 Subject: [PATCH] Add comment explaining catch. --- Reinterop~/CSharpObjectHandleUtility.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Reinterop~/CSharpObjectHandleUtility.cs b/Reinterop~/CSharpObjectHandleUtility.cs index 93c58fb0..d11d95e9 100644 --- a/Reinterop~/CSharpObjectHandleUtility.cs +++ b/Reinterop~/CSharpObjectHandleUtility.cs @@ -52,6 +52,11 @@ public static void FreeHandle(IntPtr handle) } catch (ArgumentException e) { + // The "GCHandle value belongs to a different domain" exception tends + // to happen on AppDomain reload, which is common in Unity. + // Catch the exception to prevent it propagating through our native + // code and blowing things up. + // See: https://github.com/CesiumGS/cesium-unity/issues/18 System.Console.WriteLine(e.ToString()); } }