gchar *filename;
} RuntimeConfig;
-CRITICAL_SECTION mono_delegate_section;
+mono_mutex_t mono_delegate_section;
-CRITICAL_SECTION mono_strtod_mutex;
+mono_mutex_t mono_strtod_mutex;
static gunichar2 process_guid [36];
static gboolean process_guid_set = FALSE;
mono_thread_init (start_cb, attach_cb);
class = mono_class_from_name (mono_defaults.corlib, "System", "AppDomainSetup");
- setup = (MonoAppDomainSetup *) mono_object_new (domain, class);
+ setup = (MonoAppDomainSetup *) mono_object_new_pinned (domain, class);
class = mono_class_from_name (mono_defaults.corlib, "System", "AppDomain");
- ad = (MonoAppDomain *) mono_object_new (domain, class);
+ ad = (MonoAppDomain *) mono_object_new_pinned (domain, class);
ad->data = domain;
domain->domain = ad;
domain->setup = setup;
- InitializeCriticalSection (&mono_delegate_section);
+ mono_mutex_init_recursive (&mono_delegate_section);
- InitializeCriticalSection (&mono_strtod_mutex);
+ mono_mutex_init_recursive (&mono_strtod_mutex);
mono_thread_attach (domain);
mono_context_init (domain);
MonoAppContext *context;
class = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Contexts", "Context");
- context = (MonoAppContext *) mono_object_new (domain, class);
+ context = (MonoAppContext *) mono_object_new_pinned (domain, class);
context->domain_id = domain->domain_id;
context->context_id = 0;
domain->default_context = context;
return mono_domain_from_appdomain (ad);
}
+/**
+ * mono_domain_set_config:
+ * @domain: MonoDomain initialized with the appdomain we want to change
+ * @base_dir: new base directory for the appdomain
+ * @config_file_name: path to the new configuration for the app domain
+ *
+ * Used to set the system configuration for an appdomain
+ *
+ * Without using this, embedded builds will get 'System.Configuration.ConfigurationErrorsException:
+ * Error Initializing the configuration system. ---> System.ArgumentException:
+ * The 'ExeConfigFilename' argument cannot be null.' for some managed calls.
+ */
+void
+mono_domain_set_config (MonoDomain *domain, const char *base_dir, const char *config_file_name)
+{
+ MONO_OBJECT_SETREF (domain->setup, application_base, mono_string_new (domain, base_dir));
+ MONO_OBJECT_SETREF (domain->setup, configuration_file, mono_string_new (domain, config_file_name));
+}
+
static MonoAppDomainSetup*
copy_app_domain_setup (MonoDomain *domain, MonoAppDomainSetup *setup)
{
/*
This function raises exceptions so it can cause as sorts of nasty stuff if called
while holding a lock.
+Returns old file name if shadow copy is disabled, new shadow copy file name if successful
+or NULL if source file not found.
FIXME bubble up the error instead of raising it here
*/
char *
if (copy_result == FALSE) {
g_free (shadow);
+
+ /* Fix for bug #17251 - if file not found try finding assembly by other means (it is not fatal error) */
+ if (GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND)
+ return NULL; /* file not found, shadow copy failed */
+
exc = mono_get_exception_execution_engine ("Failed to create shadow copy (CopyFile).");
mono_raise_exception (exc);
}
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
ass = tmp->data;
/* Dynamic assemblies can't match here in MS.NET */
- if (ass->dynamic || refonly != ass->ref_only || !mono_assembly_names_equal (aname, &ass->aname))
+ if (assembly_is_dynamic (ass) || refonly != ass->ref_only || !mono_assembly_names_equal (aname, &ass->aname))
continue;
mono_domain_assemblies_unlock (domain);
void *data;
if (klass->has_static_refs && (data = mono_vtable_get_static_field_data (vtable)))
- mono_gc_bzero (data, mono_class_data_size (klass));
+ mono_gc_bzero_aligned (data, mono_class_data_size (klass));
}
typedef struct unload_data {
g_free (data);
return;
}
- } while (InterlockedCompareExchange (&data->refcount, count, count - 1) != count);
+ } while (InterlockedCompareExchange (&data->refcount, count - 1, count) != count);
}
static void
* promoting it from a simple lock to a complex lock, which we better avoid if
* possible.
*/
- if (image->dynamic)
+ if (image_is_dynamic (image))
deregister_reflection_info_roots_from_list (image);
for (i = 0; i < image->module_count; ++i) {
MonoImage *module = image->modules [i];
- if (module && module->dynamic)
+ if (module && image_is_dynamic (module))
deregister_reflection_info_roots_from_list (module);
}
}