[Mono-dev] mono_add_internal_call to mscorlib method

Robert Jordan robertj at gmx.net
Fri Jun 10 09:37:32 UTC 2016

On 09.06.2016 15:37, nicob wrote:
> Hi Robert, thanks for the reply. I didn't explain my self correctly. Here's
> an example, I have a c# assembly with a method that prints the args to the
> console:

I believe I didn't explain the workaround entirely.

Parts of the Mono runtime are expecting that the main entry point
of some assembly has been executed.

Environment.GetCommandLineArgs belongs clearly to this part of
the runtime because, well, it needs data only provided
by executing the main entry point.

The trick is to invoke  mono_jit_exec () on a simple assembly
which does only this:

$ cat <<EOF > entrypoint.cs
namespace Helper {
    public static class EntryPoint {
	public static void Main ()

$ mcs /target:exe /out:entrypoint.dll entrypoint.cs

Then load entrypoint.dll and pass it to mono_jit_exec.
After this call, almost all parts of the runtime will work
as expected, including Environment.GetCommandLineArgs.
It will return what you've provided to mono_jit_exec ().


More information about the Mono-devel-list mailing list