Commit 3b4d2780 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

mscoree: Always call mono_thread_attach before invoking managed code.

parent 87e75a03
......@@ -148,6 +148,8 @@ static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *d
MonoObject *appdomain_object;
IUnknown *unk;
This->mono->mono_thread_attach(domain);
assembly = This->mono->mono_domain_assembly_open(domain, "mscorlib");
if (!assembly)
{
......@@ -560,6 +562,8 @@ static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost*
hr = E_FAIL;
This->mono->mono_thread_attach(domain);
filenameA = WtoA(pwzAssemblyPath);
assembly = This->mono->mono_domain_assembly_open(domain, filenameA);
if (!assembly)
......@@ -658,6 +662,8 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name,
if (SUCCEEDED(hr))
{
This->mono->mono_thread_attach(domain);
type = This->mono->mono_reflection_type_from_name(nameA, NULL);
if (!type)
{
......@@ -705,7 +711,9 @@ HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name,
*
* NOTE: The IUnknown* is created with a reference to the object.
* Until they have a reference, objects must be in the stack to prevent the
* garbage collector from freeing them. */
* garbage collector from freeing them.
*
* mono_thread_attach must have already been called for this thread. */
HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj,
IUnknown **ppUnk)
{
......@@ -1025,6 +1033,8 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj )
hr = CLASS_E_CLASSNOTAVAILABLE;
host->mono->mono_thread_attach(domain);
filenameA = WtoA(filename);
assembly = host->mono->mono_domain_assembly_open(domain, filenameA);
HeapFree(GetProcessHeap(), 0, filenameA);
......
......@@ -186,6 +186,7 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result)
LOAD_MONO_FUNCTION(mono_set_dirs);
LOAD_MONO_FUNCTION(mono_stringify_assembly_name);
LOAD_MONO_FUNCTION(mono_string_new);
LOAD_MONO_FUNCTION(mono_thread_attach);
/* GLib imports obsoleted by the 2.0 ABI */
if (This->mono_abi_version == 1)
......
......@@ -44,6 +44,7 @@ typedef struct _MonoObject MonoObject;
typedef struct _MonoString MonoString;
typedef struct _MonoMethod MonoMethod;
typedef struct _MonoProfiler MonoProfiler;
typedef struct _MonoThread MonoThread;
typedef struct loaded_mono loaded_mono;
typedef struct RuntimeHost RuntimeHost;
......@@ -163,6 +164,7 @@ struct loaded_mono
void (CDECL *mono_thread_suspend_all_other_threads)(void);
void (CDECL *mono_threads_set_shutting_down)(void);
MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str);
MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain);
};
/* loaded runtime interfaces */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment