diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index ce7ca2870fb840..d82a3defefeabd 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -124,7 +124,6 @@ if(CLR_CMAKE_TARGET_WIN32) version.lib shlwapi.lib bcrypt.lib - RuntimeObject.lib ) else() list(APPEND CORECLR_LIBRARIES diff --git a/src/coreclr/ilasm/CMakeLists.txt b/src/coreclr/ilasm/CMakeLists.txt index 9cc652ccbf78e5..cee70603411921 100644 --- a/src/coreclr/ilasm/CMakeLists.txt +++ b/src/coreclr/ilasm/CMakeLists.txt @@ -105,7 +105,6 @@ if(CLR_CMAKE_TARGET_WIN32) version.lib shlwapi.lib bcrypt.lib - RuntimeObject.lib coreclrminipal ) else() diff --git a/src/coreclr/ildasm/exe/CMakeLists.txt b/src/coreclr/ildasm/exe/CMakeLists.txt index 648cbc236b4746..c14148f52a3df3 100644 --- a/src/coreclr/ildasm/exe/CMakeLists.txt +++ b/src/coreclr/ildasm/exe/CMakeLists.txt @@ -86,7 +86,6 @@ if(CLR_CMAKE_HOST_WIN32) version.lib shlwapi.lib bcrypt.lib - RuntimeObject.lib coreclrminipal ) else() diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index c84224eb2136da..50c23649c2c0e5 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -597,7 +597,6 @@ else() shlwapi.lib bcrypt.lib crypt32.lib - RuntimeObject.lib coreclrminipal ) endif(CLR_CMAKE_HOST_UNIX) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs index 57b8b7ad2bdbb9..120d75b5d8cc63 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Windows.cs @@ -303,15 +303,9 @@ private static void InitializeCom(ApartmentState state = ApartmentState.MTA) if ((t_comState & ComState.InitializedByUs) != 0) return; -#if ENABLE_WINRT - int hr = Interop.WinRT.RoInitialize( - (state == ApartmentState.STA) ? Interop.WinRT.RO_INIT_SINGLETHREADED - : Interop.WinRT.RO_INIT_MULTITHREADED); -#else int hr = Interop.Ole32.CoInitializeEx(IntPtr.Zero, (state == ApartmentState.STA) ? Interop.Ole32.COINIT_APARTMENTTHREADED : Interop.Ole32.COINIT_MULTITHREADED); -#endif if (hr < 0) { // RPC_E_CHANGED_MODE indicates this thread has been already initialized with a different @@ -339,11 +333,7 @@ private static void UninitializeCom() if ((t_comState & ComState.InitializedByUs) == 0) return; -#if ENABLE_WINRT - Interop.WinRT.RoUninitialize(); -#else Interop.Ole32.CoUninitialize(); -#endif t_comState &= ~ComState.InitializedByUs; } diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 271fbf631ad979..ac6642be29b349 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -2356,20 +2356,6 @@ void Thread::BaseCoUninitialize() ::CoUninitialize(); }// BaseCoUninitialize -#ifdef FEATURE_COMINTEROP -void Thread::BaseWinRTUninitialize() -{ - STATIC_CONTRACT_THROWS; - STATIC_CONTRACT_GC_TRIGGERS; - STATIC_CONTRACT_MODE_PREEMPTIVE; - - _ASSERTE(GetThread() == this); - _ASSERTE(IsWinRTInitialized()); - - RoUninitialize(); -} -#endif // FEATURE_COMINTEROP - void Thread::CoUninitialize() { CONTRACTL { @@ -2380,30 +2366,14 @@ void Thread::CoUninitialize() // Running threads might have performed a CoInitialize which must // now be balanced. - BOOL needsUninitialize = IsCoInitialized() -#ifdef FEATURE_COMINTEROP - || IsWinRTInitialized() -#endif // FEATURE_COMINTEROP - ; - if (!IsAtProcessExit() && needsUninitialize) + if (!IsAtProcessExit() && IsCoInitialized()) { GCX_PREEMP(); CONTRACT_VIOLATION(ThrowsViolation); - if (IsCoInitialized()) - { - BaseCoUninitialize(); - ResetThreadState(TS_CoInitialized); - } - -#ifdef FEATURE_COMINTEROP - if (IsWinRTInitialized()) - { - BaseWinRTUninitialize(); - ResetWinRTInitialized(); - } -#endif // FEATURE_COMNITEROP + BaseCoUninitialize(); + ResetThreadState(TS_CoInitialized); } } #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT @@ -2590,30 +2560,13 @@ void Thread::CleanupCOMState() // now be balanced. However only the thread that called COInitialize can // call CoUninitialize. - BOOL needsUninitialize = IsCoInitialized() -#ifdef FEATURE_COMINTEROP - || IsWinRTInitialized() -#endif // FEATURE_COMINTEROP - ; - - if (needsUninitialize) + if (IsCoInitialized()) { GCX_PREEMP(); CONTRACT_VIOLATION(ThrowsViolation); - if (IsCoInitialized()) - { - BaseCoUninitialize(); - ResetCoInitialized(); - } - -#ifdef FEATURE_COMINTEROP - if (IsWinRTInitialized()) - { - BaseWinRTUninitialize(); - ResetWinRTInitialized(); - } -#endif // FEATURE_COMINTEROP + BaseCoUninitialize(); + ResetCoInitialized(); } } #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT @@ -3757,33 +3710,15 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state) // the thread. if (state == AS_Unknown) { - BOOL needUninitialize = (m_State & TS_CoInitialized) -#ifdef FEATURE_COMINTEROP - || IsWinRTInitialized() -#endif // FEATURE_COMINTEROP - ; - - if (needUninitialize) + if (m_State & TS_CoInitialized) { GCX_PREEMP(); - // If we haven't CoInitialized the thread, then we don't have anything to do. - if (m_State & TS_CoInitialized) - { - // CoUninitialize the thread and reset the STA/MTA/CoInitialized state bits. - ::CoUninitialize(); - - ThreadState uninitialized = static_cast(TS_InSTA | TS_InMTA | TS_CoInitialized); - ResetThreadState(uninitialized); - } + // CoUninitialize the thread and reset the STA/MTA/CoInitialized state bits. + ::CoUninitialize(); -#ifdef FEATURE_COMINTEROP - if (IsWinRTInitialized()) - { - BaseWinRTUninitialize(); - ResetWinRTInitialized(); - } -#endif // FEATURE_COMINTEROP + ThreadState uninitialized = static_cast(TS_InSTA | TS_InMTA | TS_CoInitialized); + ResetThreadState(uninitialized); } return GetApartment(); } @@ -3871,47 +3806,6 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state) _ASSERTE(!"Unexpected HRESULT returned from CoInitializeEx!"); } - // Since WinRT sits on top of COM we need to make sure that it is initialized - // in the same threading mode as we just started COM itself - // with (or that we detected COM had already been started with). - if (!IsWinRTInitialized()) - { - GCX_PREEMP(); - - BOOL isSTA = m_State & TS_InSTA; - _ASSERTE(isSTA || (m_State & TS_InMTA)); - - HRESULT hrWinRT = RoInitialize(isSTA ? RO_INIT_SINGLETHREADED : RO_INIT_MULTITHREADED); - - if (SUCCEEDED(hrWinRT)) - { - if (hrWinRT == S_OK) - { - SetThreadStateNC(TSNC_WinRTInitialized); - } - else - { - _ASSERTE(hrWinRT == S_FALSE); - - // If the thread has already been initialized, back it out. We may not - // always be able to call RoUninitialize on shutdown so if there's - // a way to avoid having to, we should take advantage of that. - RoUninitialize(); - } - } - else if (hrWinRT == E_OUTOFMEMORY) - { - COMPlusThrowOM(); - } - else - { - // We don't check for RPC_E_CHANGEDMODE, since we're using the mode that was read in by - // initializing COM above. COM and WinRT need to always be in the same mode, so we should never - // see that return code at this point. - _ASSERTE(!"Unexpected HRESULT From RoInitialize"); - } - } - return GetApartment(); } diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 9b5a276788dd6d..57c2383ce6dbc8 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -627,10 +627,7 @@ class Thread TSNC_DebuggerSleepWaitJoin = 0x04000000, // Indicates to the debugger that this thread is in a sleep wait or join state // This almost mirrors the TS_Interruptible state however that flag can change // during GC-preemptive mode whereas this one cannot. -#ifdef FEATURE_COMINTEROP - TSNC_WinRTInitialized = 0x08000000, // the thread has initialized WinRT -#endif // FEATURE_COMINTEROP - + // unused = 0x08000000, TSNC_TSLTakenForStartup = 0x10000000, // The ThreadStoreLock (TSL) is held by another mechanism during // thread startup so can be skipped. @@ -748,20 +745,6 @@ class Thread ResetThreadState(TS_CoInitialized); } -#ifdef FEATURE_COMINTEROP - BOOL IsWinRTInitialized() - { - LIMITED_METHOD_CONTRACT; - return HasThreadStateNC(TSNC_WinRTInitialized); - } - - void ResetWinRTInitialized() - { - LIMITED_METHOD_CONTRACT; - ResetThreadStateNC(TSNC_WinRTInitialized); - } -#endif // FEATURE_COMINTEROP - void CleanupCOMState(); #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT @@ -1119,7 +1102,6 @@ class Thread #ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT void CoUninitialize(); void BaseCoUninitialize(); - void BaseWinRTUninitialize(); #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT void CooperativeCleanup(); diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 928180b8ecdcb2..a54999241b481d 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -137,7 +137,6 @@ if(CLR_CMAKE_TARGET_WIN32) shlwapi.lib shell32.lib bcrypt.lib - RuntimeObject.lib ) # additional requirements for System.IO.Compression.Native