Handle E_NOTIMPL return from CoInitializeEx. (#24387)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Mon, 6 May 2019 20:45:52 +0000 (13:45 -0700)
committerGitHub <noreply@github.com>
Mon, 6 May 2019 20:45:52 +0000 (13:45 -0700)
* Handle E_NOTIMPL return from CoInitializeEx.

* Remove unneeded STA attributes.

20 files changed:
src/dlls/mscorrc/mscorrc.rc
src/dlls/mscorrc/resource.h
src/vm/threads.cpp
tests/src/JIT/Methodical/eh/deadcode/loopstrswitchgoto.cs
tests/src/JIT/Methodical/eh/finallyexec/switchincatch.cs
tests/src/JIT/Methodical/eh/interactions/gcincatch.cs
tests/src/JIT/Methodical/eh/interactions/strswitchfinal.cs
tests/src/JIT/Methodical/eh/interactions/switchinfinally.cs
tests/src/JIT/Methodical/eh/regress/asurt/122239/outermostFinally.cs
tests/src/JIT/Regression/VS-ia64-JIT/M00/b111192/strswitch2.cs
tests/src/JIT/Regression/VS-ia64-JIT/M00/b98431/ConsoleApplication2.il
tests/src/JIT/Regression/VS-ia64-JIT/M00/b99403/cbyte7a.il
tests/src/Loader/classloader/generics/Variance/Regressions/dev10_468712/dev10_468712.il
tests/src/Loader/classloader/regressions/91888/pumpFromCctor.cs
tests/src/baseservices/compilerservices/RuntimeHelpers/ExecuteCodeWithGuaranteedCleanup.cs
tests/src/baseservices/threading/interlocked/compareexchange/compareexchangefloat.cs
tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeintptr.cs
tests/src/baseservices/threading/interlocked/compareexchange/compareexchangeobject.cs
tests/src/baseservices/threading/interlocked/exchange/exchangefloat.cs
tests/src/baseservices/threading/interlocked/exchange/exchangeobject.cs

index 3576b48..f11d48a 100644 (file)
@@ -496,6 +496,7 @@ BEGIN
 STRINGTABLE DISCARDABLE 
 BEGIN
     CEE_E_CVTRES_NOT_FOUND                  "Could not execute CVTRES.EXE."
+    IDS_EE_THREAD_APARTMENT_NOT_SUPPORTED   "The system does not support the %1 thread apartment."
     IDS_EE_NDIRECT_UNSUPPORTED_SIG          "Method's type signature is not PInvoke compatible."
     IDS_EE_COM_UNSUPPORTED_SIG              "Method's type signature is not Interop compatible."
     IDS_EE_COM_UNSUPPORTED_TYPE             "The method returned a COM Variant type that is not Interop compatible."
index 01982d3..3d92d42 100644 (file)
 #define IDS_EE_BADMARSHAL_COPYCTORRESTRICTION      0x2647
 #define IDS_EE_BADMARSHAL_WINRT_COPYCTOR           0x2648
 #define IDS_EE_BADMARSHAL_DELEGATE_TLB_INTERFACE   0x2649
+#define IDS_EE_THREAD_APARTMENT_NOT_SUPPORTED      0x264A
\ No newline at end of file
index 73d452c..06be462 100644 (file)
@@ -5092,6 +5092,10 @@ Thread::ApartmentState Thread::SetApartment(ApartmentState state, BOOL fFireMDAO
     {
         COMPlusThrowOM();
     }
+    else if (hr == E_NOTIMPL)
+    {
+        COMPlusThrow(kPlatformNotSupportedException, IDS_EE_THREAD_APARTMENT_NOT_SUPPORTED, (state == AS_InSTA) ? W("STA") : W("MTA"));
+    }
     else
     {
         _ASSERTE(!"Unexpected HRESULT returned from CoInitializeEx!");
index 8c46521..4002b08 100644 (file)
@@ -25,7 +25,7 @@ namespace strswitch
 
             s_testLog = new TestUtil.TestLog(expectedOut);
         }
-        [STAThread]
+
         private static int Main(string[] args)
         {
             string[] s = { "one", "two", "three", "four", "five", "six" };
index fff8a5e..f355396 100644 (file)
@@ -41,7 +41,6 @@ namespace strswitch
         /// <summary>
         /// The main entry point for the application.
         /// </summary>
-        [STAThread]
         static int Main(string[] args)
         {
             string[] s = { "one", "two", "three", "four", "five", "six" };
index 6f1d5a0..e3594b4 100644 (file)
@@ -41,7 +41,6 @@ namespace test2
         /// <summary>
         /// The main entry point for the application.
         /// </summary>
-        [STAThread]
         public static int Main(String[] args)
         {
             int[] ar = new int[] { 1, 2, 3, 4, 5 };
index a65594f..cc7b14f 100644 (file)
@@ -54,7 +54,7 @@ namespace strswitch
 
             s_testLog = new TestUtil.TestLog(expectedOut);
         }
-        [STAThread]
+
         private static int Main(string[] args)
         {
             string[] s = { "one", "two", "three", "four", "five", "six" };
index 388ee9b..547e889 100644 (file)
@@ -86,7 +86,6 @@ namespace test3
         /// <summary>
         /// The main entry point for the application.
         /// </summary>
-        [STAThread]
         static int Main(string[] args)
         {
             //Start recording
index 2e78a25..dc5a137 100644 (file)
@@ -26,7 +26,7 @@ namespace test
             // Create and initialize test log object
             testLog = new TestUtil.TestLog(expectedOut);
         }
-        [STAThread]
+
         static int Main(string[] args)
         {
             int[] array = { 1, 2, 3, 4, 5, 6 };
index 8cc671a..085cd78 100644 (file)
@@ -8,7 +8,6 @@ namespace strswitch
 {
     internal class Class1
     {
-        [STAThread]
         private static int Main(string[] args)
         {
             string[] s = { "one", "two", "three", "four", "five", "six" };
index 441f334..9d0de90 100644 (file)
@@ -47,7 +47,6 @@
     .method public static int32  Main() cil managed
     {
       .entrypoint
-      .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) 
       .maxstack  2
       .locals init (bool V_0,
                int16 V_1,
index e4ada33..2d3b95f 100644 (file)
@@ -47,7 +47,6 @@
     .method public static int32 Main() cil managed
     {
       .entrypoint
-      .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) 
       .maxstack  2
       .locals init (bool V_0,
                uint8 V_1)
index 122c600..b96f8f0 100644 (file)
@@ -76,7 +76,6 @@
   .method public static int32  Main() cil managed
   {
     .entrypoint
-    .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 ) 
     .maxstack  1
     .locals init ([0] class ConsoleApplicationVB.ICovariant`1<object> y)
     IL_0000:  nop
index 3039771..f1b7f85 100644 (file)
@@ -41,8 +41,6 @@ class Test
        // post-finalization work to be done.
        const int maxIterations = 10;
 
-       // STA
-       [STAThread]
        static int Main()
        {
                MyFinalizeObject mfo;
index 58cee3c..40b92b7 100644 (file)
@@ -40,7 +40,6 @@ namespace GCD
         /// <summary>
         /// The main entry point for the application.
         /// </summary>
-        [STAThread]
             static int Main(string[] args)
             {
                 GCD gcd = new GCD();
index 9ffe170..a7ce330 100644 (file)
@@ -15,7 +15,6 @@ namespace Exchange
                /// <summary>
                /// The main entry point for the application.
                /// </summary>
-               [STAThread]
                static int Main(string[] args)
                {
                        int loops = 100;
index 9010b3e..572435c 100644 (file)
@@ -16,7 +16,6 @@ namespace Exchange
                /// <summary>
                /// The main entry point for the application.
                /// </summary>
-               [STAThread]
                static int Main(string[] args)
                {
                        int rValue = 0;
index f135e15..c645513 100644 (file)
@@ -16,7 +16,6 @@ namespace Exchange
                /// <summary>
                /// The main entry point for the application.
                /// </summary>
-               [STAThread]
                static int Main(string[] args)
                {
                        int rValue = 0;
index 0811db9..34bc335 100644 (file)
@@ -15,7 +15,6 @@ namespace Exchange
         /// <summary>
         /// The main entry point for the application.
         /// </summary>
-        [STAThread]
         static int Main(string[] args)
         {
             int rValue = 0;
index 09fa32a..76da18a 100644 (file)
@@ -15,7 +15,6 @@ namespace InteropTests
         /// <summary>
         /// The main entry point for the application.
         /// </summary>
-        [STAThread]
         static int Main(string[] args)
         {
             int rValue = 0;