From 0b3795eb87fedf8a26b76a2139d1a1286a6e43e3 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Wed, 26 Jan 2022 22:52:54 +0600 Subject: [PATCH] Disable loading of additional assemblies in AOT context (#314) * Disable loading of additional assemblies in AOT context AOT does not supports `Assembly.Load` and `Assembly.GetReferencedAssemblies()` when running AOT. I opt-out of code which try to find type. In AOT context this means that you rely on dynamic type loading and you have issues anyway. * Fix compilation errors --- Source/Libs/GLibSharp/GType.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Libs/GLibSharp/GType.cs b/Source/Libs/GLibSharp/GType.cs index 115e53dcb..8fceea7c7 100644 --- a/Source/Libs/GLibSharp/GType.cs +++ b/Source/Libs/GLibSharp/GType.cs @@ -28,6 +28,7 @@ namespace GLib { using System.Collections.Generic; using System.IO; using System.Reflection; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -238,7 +239,11 @@ namespace GLib { break; } - if (result == null) { + if (result == null +#if NET6_0_OR_GREATER + && RuntimeFeature.IsDynamicCodeSupported +#endif + ) { // Because of lazy loading of references, it's possible the type's assembly // needs to be loaded. We will look for it by name in the references of // the currently loaded assemblies. Hopefully a recursive traversal is