Code in .NET and Mono is distributed in assemblies, there are shipped typically in files with the extension .exe or .dll, and they are files that extend the Portable Executable file format to include the Common Intermediate Language metadata and portable code.
Assemblies are typically loaded either from a given file path, or using an Assembly Name to load them from the Global Assembly Cache.
The Mono Assembly API contains method for dealing with assembly names, loading assemblies, accessing assembly components, modules and some advanced features.
Assemblies contain one or
more images, the actual vessels for your code.
The Image API documents the
functions that operate on MonoImage *
.
mono_assembly_close
assembly | the assembly to release. |
This method releases a reference to the assembly. The assembly is only released when all the outstanding references to it are released.
mono_assembly_get_object
domain | an app domain |
assembly | an assembly |
System.Reflection.Assembly
object representing the MonoAssembly
assembly.
mono_assembly_load
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 |
NULL
on error. On error the
value pointed by status is updated with an error code.
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
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. |
NULL
on error. On error the
value pointed by status is updated with an error code.
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
aname | an assembly to look for. |
NULL
If the given aname assembly has not been loaded, or a pointer to
a MonoAssembly
that matches the MonoAssemblyName
specified.This is used to determine if the specified assembly has been loaded
mono_assembly_load_from
image | Image to load the assembly from |
fname | assembly name to associate with the assembly |
status | return status code |
MonoAssembly*
on success and then status will be
set to MONO_IMAGE_OK
; or NULL
on error.
If there is an error loading the assembly the status will indicate the
reason with status being set to MONO_IMAGE_INVALID
if the
image did not contain an assembly reference table.
If the provided image has an assembly reference, it will process the given image as an assembly with the given name.
Most likely you want to use the `api:mono_assembly_load_full` method instead.
This is equivalent to calling `api:mono_assembly_load_from_full` with the
refonly parameter set to FALSE
.
mono_assembly_load_from_full
image | Image to load the assembly from |
fname | assembly name to associate with the assembly |
status | returns the status condition |
refonly | Whether this assembly is being opened in "reflection-only" mode. |
MonoAssembly*
on success and the status will be
set to MONO_IMAGE_OK
; or NULL
on error.
If there is an error loading the assembly the status will indicate the
reason with status being set to MONO_IMAGE_INVALID
if the
image did not contain an assembly reference table.
If the provided image has an assembly reference, it will process the given image as an assembly with the given name.
Most likely you want to use the `api:mono_assembly_load_full` method instead.
mono_assembly_load_with_partial_name
name | an assembly name that is then parsed by `api:mono_assembly_name_parse`. |
status | return status code |
NULL
on failure, or a pointer to a MonoAssembly
on success.
Loads a MonoAssembly
from a name. The name is parsed using `api:mono_assembly_name_parse`,
so it might contain a qualified type name, version, culture and token.
This will load the assembly from the file whose name is derived from the assembly name
by appending the .dll
extension.
The assembly is loaded from either one of the extra Global Assembly Caches specified
by the extra GAC paths (specified by the MONO_GAC_PREFIX
environment variable) or
if that fails from the GAC.
mono_assembly_open
filename | Opens the assembly pointed out by this name |
status | return status code |
MonoAssembly
if filename contains a valid
assembly or NULL
on error. Details about the error are stored in the
status variable.
This loads an assembly from the specified filename. The filename allows
a local URL (starting with a file://
prefix). If a file prefix is used, the
filename is interpreted as a URL, and the filename is URL-decoded. Otherwise the file
is treated as a local path.
First, an attempt is made to load the assembly from the bundled executable (for those
deployments that have been done with the mkbundle
tool or for scenarios where the
assembly has been registered as an embedded assembly). If this is not the case, then
the assembly is loaded from disk using `api:mono_image_open_full`.
If the pointed assembly does not live in the Global Assembly Cache, a shadow copy of the assembly is made.
mono_assembly_open_full
filename | the file to load |
status | return status code |
refonly | Whether this assembly is being opened in "reflection-only" mode. |
NULL
on error, with the status set to an error code, or a pointer
to the assembly.
This loads an assembly from the specified filename. The filename allows
a local URL (starting with a file://
prefix). If a file prefix is used, the
filename is interpreted as a URL, and the filename is URL-decoded. Otherwise the file
is treated as a local path.
First, an attempt is made to load the assembly from the bundled executable (for those
deployments that have been done with the mkbundle
tool or for scenarios where the
assembly has been registered as an embedded assembly). If this is not the case, then
the assembly is loaded from disk using `api:mono_image_open_full`.
If the pointed assembly does not live in the Global Assembly Cache, a shadow copy of the assembly is made.
If refonly is set to true, then the assembly is loaded purely for inspection with
the System.Reflection
API.
mono_set_assemblies_path
path | list of paths that contain directories where Mono will look for assemblies |
Use this method to override the standard assembly lookup system and
override any assemblies coming from the GAC. This is the method
that supports the MONO_PATH
variable.
Notice that MONO_PATH
and this method are really a very bad idea as
it prevents the GAC from working and it prevents the standard
resolution mechanisms from working. Nonetheless, for some debugging
situations and bootstrapping setups, this is useful to have.
mono_set_rootdir
Registers the root directory for the Mono runtime, for Linux and Solaris 10, this auto-detects the prefix where Mono was installed.
mono_assembly_fill_assembly_name
image | Image |
aname | Name |
TRUE
if successful
mono_assembly_foreach
func | function to invoke for each assembly loaded |
user_data | data passed to the callback |
Invokes the provided func callback for each assembly loaded into
the runtime. The first parameter passed to the callback is the
MonoAssembly*
, and the second parameter is the user_data.
This is done for all assemblies loaded in the runtime, not just those loaded in the current application domain.
mono_assembly_get_image
assembly | The assembly to retrieve the image from |
MonoImage
associated with this assembly.
mono_assembly_get_main
mono_assembly_get_name
assembly | The assembly to retrieve the name from |
MonoAssemblyName
associated with this assembly.
The returned name's lifetime is the same as assembly's.
mono_assembly_getrootdir
Obtains the root directory used for looking up assemblies.
mono_assembly_get_assemblyref
image | pointer to the MonoImage to extract the information from. |
index | index to the assembly reference in the image. |
aname | pointer to a MonoAssemblyName that will hold the returned value. |
Fills out the aname with the assembly name of the index assembly reference in image.
mono_assembly_loaded_full
aname | an assembly to look for. |
refonly | Whether this assembly is being opened in "reflection-only" mode. |
NULL
If the given aname assembly has not been loaded, or a pointer to
a MonoAssembly
that matches the MonoAssemblyName
specified.This is used to determine if the specified assembly has been loaded
mono_assembly_load_reference
mono_assembly_load_references
image | |
status |
This method is now a no-op, it does nothing other than setting the status to MONO_IMAGE_OK
mono_assembly_load_module
mono_assembly_invoke_load_hook
mono_assembly_invoke_search_hook
mono_assembly_set_main
mono_assembly_setrootdir
root_dir | The pathname of the root directory where we will locate assemblies |
This routine sets the internal default root directory for looking up assemblies.
This is used by Windows installations to compute dynamically the place where the Mono assemblies are located.
mono_register_config_for_assembly
mono_register_symfile_for_assembly
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_new
name | name to parse |
NULL
if there was any failure.
Allocate a new MonoAssemblyName
and fill its values from the
passed name.
mono_assembly_name_get_name
mono_assembly_name_get_culture
mono_assembly_name_get_version
mono_assembly_name_get_pubkeytoken
mono_assembly_name_free
aname | assembly name to free |
Frees the provided assembly name object. (it does not frees the object itself, only the name members).
mono_stringify_assembly_name
aname | the assembly name. |
Convert aname into its string format. The returned string is dynamically allocated and should be freed by the caller.
mono_assembly_names_equal
l | first assembly |
r | second assembly. |
TRUE
if both assembly names are equal.
Compares two MonoAssemblyName
instances and returns whether they are equal.
This compares the names, the cultures, the release version and their public tokens.
An assembly is made up of one or more modules.
mono_module_file_get_object
mono_module_get_object
mono_install_assembly_load_hook
mono_install_assembly_search_hook
mono_install_assembly_refonly_search_hook
mono_install_assembly_preload_hook
mono_install_assembly_refonly_preload_hook
mono_install_assembly_postload_search_hook