From 9263b92a4ba3707b6b492c90d4b1102a745f84da Mon Sep 17 00:00:00 2001 From: Howard Kapustein Date: Wed, 11 May 2022 18:09:01 -0700 Subject: [PATCH] Remove the 'if (Assembly.GetEntryAssembly() != Assembly.GetExecutingAssembly()) { return; }' shortcircuit as it catches loading for reflection AND for common test cases e.g. 'te.exe foo.dll' as auto-initialization isn't restricted to exes (i.e. it gets compiled into foo.dll) and then Entry!=Executing. Revert this for now and restore later when #2456 is addressed (by restrcting auto-init to only compile into exes) --- .../UndockedRegFreeWinRT-AutoInitializer.cs | 6 ------ .../MddBootstrapAutoInitializer.cs | 6 ------ 2 files changed, 12 deletions(-) diff --git a/dev/UndockedRegFreeWinRT/UndockedRegFreeWinRT-AutoInitializer.cs b/dev/UndockedRegFreeWinRT/UndockedRegFreeWinRT-AutoInitializer.cs index 52e9049921..7180eb6198 100644 --- a/dev/UndockedRegFreeWinRT/UndockedRegFreeWinRT-AutoInitializer.cs +++ b/dev/UndockedRegFreeWinRT/UndockedRegFreeWinRT-AutoInitializer.cs @@ -17,12 +17,6 @@ class AutoInitialize [global::System.Runtime.CompilerServices.ModuleInitializer] internal static void AccessWindowsAppSDK() { - // Do nothing if we're being loaded for reflection (rather than execcution) - if (Assembly.GetEntryAssembly() != Assembly.GetExecutingAssembly()) - { - return; - } - // No error handling needed as the target function does nothing (just {return S_OK}). // It's the act of calling the function causing the DllImport to load the DLL that // matters. This provides the moral equivalent of a native DLL's Import Address diff --git a/dev/WindowsAppRuntime_BootstrapDLL/MddBootstrapAutoInitializer.cs b/dev/WindowsAppRuntime_BootstrapDLL/MddBootstrapAutoInitializer.cs index 3a79bcbb4b..d86a6a50c8 100644 --- a/dev/WindowsAppRuntime_BootstrapDLL/MddBootstrapAutoInitializer.cs +++ b/dev/WindowsAppRuntime_BootstrapDLL/MddBootstrapAutoInitializer.cs @@ -26,12 +26,6 @@ class AutoInitialize [global::System.Runtime.CompilerServices.ModuleInitializer] internal static void AccessWindowsAppSDK() { - // Do nothing if we're being loaded for reflection (rather than execcution) - if (Assembly.GetEntryAssembly() != Assembly.GetExecutingAssembly()) - { - return; - } - uint majorMinorVersion = global::Microsoft.WindowsAppSDK.Release.MajorMinor; string versionTag = global::Microsoft.WindowsAppSDK.Release.VersionTag; var minVersion = new PackageVersion(global::Microsoft.WindowsAppSDK.Runtime.Version.UInt64);