[reflection] MonoError for mono_reflection_type_get_handle
[mono.git] / mono / metadata / security-manager.c
index 2de7972026a8921f987f14ccd1ea385abd5b3c2d..e3c3cbc82d57a033d5ba8ba57de299dd7468fdbc 100644 (file)
@@ -11,6 +11,7 @@
 
 /* Class lazy loading functions */
 static GENERATE_GET_CLASS_WITH_CACHE (security_manager, System.Security, SecurityManager)
+static GENERATE_TRY_GET_CLASS_WITH_CACHE (execution_context, System.Threading, ExecutionContext)
 
 static MonoSecurityMode mono_security_mode = MONO_SECURITY_MODE_NONE;
 
@@ -96,9 +97,10 @@ mono_get_context_capture_method (void)
                return NULL;
 
        /* older corlib revisions won't have the class (nor the method) */
-       if (mono_defaults.executioncontext_class && !method) {
-               mono_class_init (mono_defaults.executioncontext_class);
-               method = mono_class_get_method_from_name (mono_defaults.executioncontext_class, "Capture", 0);
+       MonoClass *execution_context = mono_class_try_get_execution_context_class ();
+       if (execution_context && !method) {
+               mono_class_init (execution_context);
+               method = mono_class_get_method_from_name (execution_context, "Capture", 0);
        }
 
        return method;