mono-api-assembly.html

Assemblies

Synopsis

#include <metadata/assembly.h> typedef struct _MonoImage MonoImage; typedef struct _MonoAssembly MonoAssembly; MonoAssembly* mono_assembly_open (const char *filename, MonoImageOpenStatus *status); void mono_assembly_close (MonoAssembly *assembly); MonoAssembly* mono_assembly_load (MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status); MonoAssembly* mono_assembly_load_full (MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status, gboolean refonly); MonoAssembly* mono_assembly_loaded (MonoAssemblyName *aname); MonoImage* mono_assembly_get_image (MonoAssembly *assembly); MonoAssembly* mono_assembly_get_main (void); G_CONST_RETURN gchar * mono_assembly_getrootdir (void); void mono_assembly_name_free (MonoAssemblyName *aname); char* mono_stringify_assembly_name (MonoAssemblyName *aname); gboolean mono_assembly_names_equal (MonoAssemblyName *l, MonoAssemblyName *r);

Assembly Loading

mono_assembly_open
MonoAssembly* mono_assembly_open (const char *filename, MonoImageOpenStatus *status)

Parameters

filename:
Opens the assembly pointed out by this name
status:
where a status code can be returned
Returns
a pointer to the MonoAssembly if filename contains a valid assembly or NULL on error. Details about the error are stored in the status variable.
Remarks

mono_assembly_open opens the PE-image pointed by filename, and loads any external assemblies referenced by it.

mono_assembly_close
void mono_assembly_close (MonoAssembly *assembly)

Parameters

assembly:
the assembly to release.
Remarks

This method releases a reference to the assembly. The assembly is only released when all the outstanding references to it are released.

mono_assembly_load
MonoAssembly* mono_assembly_load (MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status)

Parameters

aname:
A MonoAssemblyName with the assembly name to load.
basedir:
A directory to look up the assembly at.
status:
a pointer to a MonoImageOpenStatus to return the status of the load operation
Returns
the assembly referenced by aname loaded or NULL on error. On error the value pointed by status is updated with an error code.
Remarks

Loads the assembly referenced by aname, if the value of basedir is not NULL, it attempts to load the assembly from that directory before probing the standard locations.

mono_assembly_load_full
MonoAssembly* mono_assembly_load_full (MonoAssemblyName *aname, const char *basedir, MonoImageOpenStatus *status, gboolean refonly)

Parameters

aname:
A MonoAssemblyName with the assembly name to load.
basedir:
A directory to look up the assembly at.
status:
a pointer to a MonoImageOpenStatus to return the status of the load operation
refonly:
Whether this assembly is being opened in "reflection-only" mode.
Returns
the assembly referenced by aname loaded or NULL on error. On error the value pointed by status is updated with an error code.
Remarks

Loads the assembly referenced by aname, if the value of basedir is not NULL, it attempts to load the assembly from that directory before probing the standard locations. If the assembly is being opened in reflection-only mode (refonly set to TRUE) then no assembly binding takes place.

mono_assembly_loaded
MonoAssembly* mono_assembly_loaded (MonoAssemblyName *aname)

Parameters

aname:
an assembly to look for.
Returns
NULL If the given aname assembly has not been loaded, or a pointer to a MonoAssembly that matches the MonoAssemblyName specified.
mono_assembly_get_object
Prototype: mono_assembly_get_object

Working with Assemblies

mono_assembly_get_image
MonoImage* mono_assembly_get_image (MonoAssembly *assembly)

Parameters

assembly:
The assembly to retrieve the image from
Returns
the MonoImage associated with this assembly.
mono_assembly_get_main
MonoAssembly* mono_assembly_get_main (void)

Returns

the assembly for the application, the first assembly that is loaded by the VM
mono_assembly_getrootdir
G_CONST_RETURN gchar * mono_assembly_getrootdir (void)

Returns

a string with the directory, this string should not be freed.
Remarks

Obtains the root directory used for looking up assemblies.

Assembly Names

The MonoAssemblyName contains the full identity of an assembly (name, culture, public key, public key token, version and any other flags).

These unmanaged objects represent the System.Reflection.AssemblyName managed type.

mono_assembly_name_free
void mono_assembly_name_free (MonoAssemblyName *aname)

Parameters

aname:
assembly name to free
Remarks

Frees the provided assembly name object. (it does not frees the object itself, only the name members).

mono_stringify_assembly_name
char* mono_stringify_assembly_name (MonoAssemblyName *aname)

Parameters

aname:
the assembly name.
Returns
a newly allocated string with a string representation of the assembly name.
Remarks

Convert aname into its string format. The returned string is dynamically allocated and should be freed by the caller.

mono_assembly_names_equal
gboolean mono_assembly_names_equal (MonoAssemblyName *l, MonoAssemblyName *r)

Parameters

l:
first assembly
r:
second assembly.
Returns
TRUE if both assembly names are equal.
Remarks

Compares two MonoAssemblyNames and returns whether they are equal. This compares the names, the cultures, the release version and their public tokens.

Modules

An assembly is made up of one or more modules.

mono_module_file_get_object
Prototype: mono_module_file_get_object

mono_module_get_object
Prototype: mono_module_get_object