diff --git a/src/coreclr/vm/methodtable.cpp b/src/coreclr/vm/methodtable.cpp index 27dfd82a691ed9..bebe82d2927835 100644 --- a/src/coreclr/vm/methodtable.cpp +++ b/src/coreclr/vm/methodtable.cpp @@ -4360,7 +4360,10 @@ void MethodTable::DoFullyLoad(Generics::RecursionGraph * const pVisited, const ClassLoader::ValidateMethodsWithCovariantReturnTypes(this); } - if ((level == CLASS_LOADED) && CORDisableJITOptimizations(this->GetModule()->GetDebuggerInfoBits()) && !HasInstantiation()) + if ((level == CLASS_LOADED) && + CORDisableJITOptimizations(this->GetModule()->GetDebuggerInfoBits()) && + !HasInstantiation() && + !GetModule()->GetDomainAssembly()->IsLoading()) // Do not do this during the vtable fixup stage of C++/CLI assembly loading. See https://github.com/dotnet/runtime/issues/110365 { if (g_fEEStarted) { diff --git a/src/tests/Interop/IJW/IjwNativeCallingManagedDll/IjwNativeCallingManagedDll.cpp b/src/tests/Interop/IJW/IjwNativeCallingManagedDll/IjwNativeCallingManagedDll.cpp index 15e7098774db27..e581c7ae185e11 100644 --- a/src/tests/Interop/IJW/IjwNativeCallingManagedDll/IjwNativeCallingManagedDll.cpp +++ b/src/tests/Interop/IJW/IjwNativeCallingManagedDll/IjwNativeCallingManagedDll.cpp @@ -17,10 +17,22 @@ extern "C" DLL_EXPORT int __cdecl NativeEntryPoint() } #pragma managed + +// Needed to provide a regression case for https://github.com/dotnet/runtime/issues/110365 +[assembly:System::Diagnostics::DebuggableAttribute(true, true)]; +[module:System::Diagnostics::DebuggableAttribute(true, true)]; + +public value struct ValueToReturnStorage +{ + int valueToReturn; + bool valueSet; +}; + +// store the value to return in an appdomain local static variable to allow this test to be a regression test for https://github.com/dotnet/runtime/issues/110365 +static __declspec(appdomain) ValueToReturnStorage s_valueToReturnStorage; + public ref class TestClass { -private: - static int s_valueToReturn = 100; public: int ManagedEntryPoint() { @@ -29,12 +41,16 @@ public ref class TestClass static void ChangeReturnedValue(int i) { - s_valueToReturn = i; + s_valueToReturnStorage.valueToReturn = i; + s_valueToReturnStorage.valueSet = true; } static int GetReturnValue() { - return s_valueToReturn; + if (s_valueToReturnStorage.valueSet) + return s_valueToReturnStorage.valueToReturn; + else + return 100; } };