mono-api-domains.html

Application Domains

Synopsis

#include <metadata/appdomain.h> /* Managed AppDomain */ typedef struct _MonoAppDomain MonoAppDomain; /* Unmanaged representation */ typedef struct _MonoDomain MonoDomain; /* Represents System.Runtime.Remoting.Contexts.Context */ typedef struct _MonoAppContext MonoAppContext MonoAssembly* mono_domain_assembly_open (MonoDomain *domain, const char *name); gboolean mono_domain_finalize (MonoDomain *domain, guint32 timeout) ; MonoDomain* mono_domain_get_by_id (gint32 domainid) ; MonoDomain* mono_domain_get (); gboolean mono_domain_has_type_resolve (MonoDomain *domain); void mono_domain_set_internal (MonoDomain *domain); gboolean mono_domain_set (MonoDomain *domain, gboolean force); MonoReflectionAssembly* mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb); gboolean mono_domain_owns_vtable_slot (MonoDomain *domain, gpointer vtable_slot);

Application domains are used to isolate multiple applications on a single Mono virtual machine. They are conceptually similiar to processes, the difference is that processes are managed by the operating system, while application domains are managed by the Mono virtual machine.

For more information on applications domains see the AppDomain FAQ.

The MonoDomain is the unmanaged representation of the System.AppDomain managed type, while the MonoAppDomain type represents the managed version (MonoAppDomain has a pointer to a MonoDomain).

mono_domain_assembly_open
MonoAssembly* mono_domain_assembly_open (MonoDomain *domain, const char *name)

Parameters

domain:
the application domain
name:
file name of the assembly
Remarks

fixme: maybe we should integrate this with mono_assembly_open ??

mono_domain_create
Prototype: mono_domain_create

mono_domain_finalize
gboolean mono_domain_finalize (MonoDomain *domain, guint32 timeout)

Parameters

domain:
the domain to finalize
timeout:
msects to wait for the finalization to complete, -1 to wait indefinitely
Returns
TRUE if succeeded, FALSE if there was a timeout
Remarks

Request finalization of all finalizable objects inside domain. Wait timeout msecs for the finalization to complete.

mono_domain_foreach
Prototype: mono_domain_foreach

mono_domain_free
Prototype: mono_domain_free

mono_domain_get_by_id
Prototype: mono_domain_get_by_id

mono_domain_get_id
MonoDomain* mono_domain_get_by_id (gint32 domainid)

Parameters

domainid:
the ID
Returns
the a domain for a specific domain id.
mono_domain_get
MonoDomain* mono_domain_get ()

Returns

the current domain, to obtain the root domain use mono_get_root_domain().
mono_domain_has_type_resolve
gboolean mono_domain_has_type_resolve (MonoDomain *domain)

Parameters

domain:
application domains being looked up
Remarks

Returns true if the AppDomain.TypeResolve field has been set.

mono_domain_is_unloading
Prototype: mono_domain_is_unloading

mono_domain_set_internal
void mono_domain_set_internal (MonoDomain *domain)

Parameters

domain:
the new domain
Remarks

Sets the current domain to domain.

mono_domain_set
gboolean mono_domain_set (MonoDomain *domain, gboolean force)

Parameters

domain:
domain
force:
force setting.
Returns
TRUE on success; FALSE if the domain is unloaded
Remarks

Set the current appdomain to domain. If force is set, set it even if it is being unloaded.

mono_domain_try_type_resolve
MonoReflectionAssembly* mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb)

Parameters

domain:
application domainwhere the name where the type is going to be resolved
name:
the name of the type to resolve or NULL.
tb:
A System.Reflection.Emit.TypeBuilder, used if name is NULL.
Returns
A MonoReflectionAssembly or NULL if not found
Remarks

This routine invokes the internal System.AppDomain.DoTypeResolve and returns the assembly that matches name. If name is null, the value of ((TypeBuilder)tb).FullName is used instead

mono_domain_owns_vtable_slot
gboolean mono_domain_owns_vtable_slot (MonoDomain *domain, gpointer vtable_slot)

Remarks

Returns whenever VTABLE_SLOT is inside a vtable which belongs to DOMAIN.

Contexts

mono_context_get
Prototype: mono_context_get