1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
|
<?xml version="1.0" encoding="us-ascii"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>mono-api-embedding.html</title>
<style type="text/css">
.mapi-docs {
line-height: 1.5;
padding-left: 2em;
padding-right: 2em;
}
.mapi-docs p {
max-width: 60em;
}
.mapi-docs .mapi-body {
max-width: 60em;
}
.mapi-docs code {
border: 1px solid rgba(214,214,214,1);
background-color: rgba(249,249,249,1);
padding: 0.1em 0.5em;
}
.mapi-description code {
font-family: "Consolas", "Courier", monospace;
border: 1px solid rgba(214,214,214,1);
background-color: rgba(249,249,249,1);
padding: 0.1em 0.2em;
}
.mapi-header {
padding: 0 0 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
border: 1px solid rgba(233,233,233,1);
background-color: rgba(249,249,249,1);
}
.mapi-code {
padding: 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
border: 1px solid rgba(233,233,233,1);
background-color: rgba(249,249,249,1);
}
.mapi-code:first-line {
line-height: 0px;
}
.mapi-codeblock {
display: block;
padding: 5pt 5pt;
margin: 10pt;
white-space: pre;
font-family: monospace;
border: 1px solid rgba(233,233,233,1);
background-color: rgba(249,249,249,1);
}
.mapi-entry code {
border: none;
background-color: transparent;
}
.mapi-parameters {
border-collapse: collapse;
border-spacing: 0;
empty-cells: hide;
border: 0;
margin: 5px 0 26px;
}
.mapi-parameters td {
border: 1px solid rgba(214,214,214,1);
border-left-style: none;
padding: 5px 25px 5px 10px;
}
.mapi-parameters tr>td:last-child {
border-right: 0;
}
.mapi-parameters td:first-of-type {
text-align: right;
padding: 7px;
vertical-align: top;
word-break: normal;
width: 40px;
}
.mapi-parameters tr:last-child>td {
border-bottom: 0;
}
.mapi-parameters tr:first-child>td {
border-top: 0;
}
.mapi-parameters tr td:first-of-type {
text-align: right;
padding: 7px;
vertical-align: top;
word-break: normal;
width: 40px;
}
.mapi {
left: -25px;
margin: 0;
padding: 13px 25px 0;
position: relative;
width: 100%;
}
.mapi-description {
background: rgba(249,249,249,1);
border-bottom: 1px solid rgba(233,233,233,1);
left: -25px;
margin: 0;
padding: 13px 25px 0;
position: relative;
width: 100%;
}
.mapi-entry {
background: transparent;
}
.mapi-docs {
}
.mapi-prototype {
border-left: 5px solid rgba(205,233,244,1);
padding: .5em;
margin-top: 5pt;
margin-bottom: 5pt;
font-family: "Consolas", "Courier", monospace;
display: block;
overflow: auto;
background-color: #f9f9f9;
}
.mapi-declaration {
margin-top: 21px;
}
.mapi-section {
font-size: smaller;
font-weight: bold;
margin-top: 21px;
line-height: 1.5;
}
.mapi-strike {
text-decoration: line-through;
}
.mapi-deprecated {
color: red;
}
.mapi-ptr-container {
background: white;
border-bottom: 1px solid rgba(233,233,233,1);
left: -25px;
padding-left: 25px;
padding-right: 25px;
padding-bottom: 13px;
position: relative;
width: 100%;
}
.mapi-ptr {
background: rgba(249,249,249,1);
border-left: 1px solid rgba(233,233,233,1);
border-top: 1px solid rgba(233,233,233,1);
height: 12px;
left: 37px;
top: -7px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
width: 12px;
}
.mapi-height-container {
left: -25px;
padding: 0 25px;
position: relative;
width: 100%;
}
</style>
</head>
<body>
<div class="mapi-docs">
<h2>Embedding Mono</h2>
<p />The Mono runtime can be embedded into C and C++
applications. Your C/C++ code can invoke managed code
running in the Mono/.NET world and you can also surface your
internal application APIs to Mono and .NET.
<p />For an overview of how to embed Mono into your application
and the strategies that you can use to embed Mono, check the
Mono
website's <a href="http://www.mono-project.com/docs/advanced/embedding/">Embedding
Mono</a> page.
<p />This page is the companion API reference for the above guide.
<p />The simplest way of embedding Mono is illustrated here:
<pre>
int main (int argc, char *argv)
{
/*
* Load the default Mono configuration file, this is needed
* if you are planning on using the dllmaps defined on the
* system configuration
*/
mono_config_parse (NULL);
/*
* mono_jit_init() creates a domain: each assembly is
* loaded and run in a MonoDomain.
*/
MonoDomain *domain = mono_jit_init ("startup.exe");
/*
* Optionally, add an internal call that your startup.exe
* code can call, this will bridge startup.exe to Mono
*/
mono_add_internal_call ("Sample::GetMessage", getMessage);
/*
* Open the executable, and run the Main method declared
* in the executable
*/
MonoAssembly *assembly = mono_domain_assembly_open (domain, "startup.exe");
if (!assembly)
exit (2);
/*
* mono_jit_exec() will run the Main() method in the assembly.
* The return value needs to be looked up from
* System.Environment.ExitCode.
*/
mono_jit_exec (domain, assembly, argc, argv);
}
/* The C# signature for this method is: string GetMessage () in class Sample */
MonoString*
getMessage ()
{
return mono_string_new (mono_domain_get (), "Hello, world");
}
</pre>
<a name="api:mono_jit_init"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_init</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">MonoDomain*
mono_jit_init (const char *file)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_jit_parse_options"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_parse_options</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_jit_parse_options (int argc, char * argv[])
</div>
<p />
<div class="mapi-section">Description</div>
<div>
<p />
Process the command line options in <i>argv</i> as done by the runtime executable.
This should be called before <code>mono_jit_init</code>.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_jit_exec"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_exec</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">int
mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>assembly</i></td><td> reference to an assembly</td></tr><tr><td><i>argc</i></td><td> argument count</td></tr><tr><td><i>argv</i></td><td> argument vector</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Start execution of a program.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_set_dirs"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_set_dirs</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_set_dirs (const char *assembly_dir, const char *config_dir)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>assembly_dir</i></td><td> the base directory for assemblies</td></tr><tr><td><i>config_dir</i></td><td> the base directory for configuration files</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
<p />
This routine is used internally and by developers embedding
the runtime into their own applications.
<p />
There are a number of cases to consider: Mono as a system-installed
package that is available on the location preconfigured or Mono in
a relocated location.
<p />
If you are using a system-installed Mono, you can pass <code>NULL</code>
to both parameters. If you are not, you should compute both
directory values and call this routine.
<p />
The values for a given PREFIX are:
<p />
assembly_dir: PREFIX/lib
config_dir: PREFIX/etc
<p />
Notice that embedders that use Mono in a relocated way must
compute the location at runtime, as they will be in control
of where Mono is installed.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_parse_default_optimizations"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_parse_default_optimizations</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">int
mono_parse_default_optimizations (const char* p)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_runtime_set_main_args"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_runtime_set_main_args</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">int
mono_runtime_set_main_args (int argc, char* argv[])
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>argc</i></td><td> number of arguments from the command line</td></tr><tr><td><i>argv</i></td><td> array of strings from the command line</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Set the command line arguments from an embedding application that doesn't otherwise call
<code>mono_runtime_run_main</code>.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_jit_cleanup"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_cleanup</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_jit_cleanup (MonoDomain *domain)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_jit_set_trace_options"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_set_trace_options</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">gboolean
mono_jit_set_trace_options (const char* options)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>options</i></td><td> string representing the trace options</td></tr></tbody></table> <div class="mapi-section">Return value</div>
<div> <code>TRUE</code> if the options were parsed and set correctly, <code>FALSE</code> otherwise.
</div>
<div class="mapi-section">Description</div>
<div>
Set the options of the tracing engine. This function can be called before initializing
the mono runtime. See the --trace mono(1) manpage for the options format.
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
<h3>Internal Calls</h3>
<p />The Mono runtime provides two mechanisms to expose C code
to the CIL universe: internal calls and native C
code. Internal calls are tightly integrated with the runtime,
and have the least overhead, as they use the same data types
that the runtime uses.
<p />The other option is to use the Platform Invoke (P/Invoke)
to call C code from the CIL universe, using the standard
<a href="http://www.mono-project.com/Interop_with_Native_Libraries">P/Invoke</a>
mechanisms.
<p />To register an internal call, use this call you use the
<a href="#api:mono_add_internal_call"><tt>mono_add_internal_call</tt>
routine.
</a></div> <!-- class=mapi -->
<a name="api:mono_add_internal_call"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_add_internal_call</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_add_internal_call (const char *name, gconstpointer method)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>name</i></td><td> method specification to surface to the managed world</td></tr><tr><td><i>method</i></td><td> pointer to a C method to invoke when the method is called</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
<p />
This method surfaces the C function pointed by <i>method</i> as a method
that has been surfaced in managed code with the method specified in
<i>name</i> as an internal call.
<p />
Internal calls are surfaced to all app domains loaded and they are
accessibly by a type with the specified name.
<p />
You must provide a fully qualified type name, that is namespaces
and type name, followed by a colon and the method name, with an
optional signature to bind.
<p />
For example, the following are all valid declarations:
<p />
<code>MyApp.Services.ScriptService:Accelerate</code>
<p />
<code>MyApp.Services.ScriptService:Slowdown(int,bool)</code>
<p />
You use method parameters in cases where there might be more than
one surface method to managed code. That way you can register different
internal calls for different method overloads.
<p />
The internal calls are invoked with no marshalling. This means that .NET
types like <code>System.String</code> are exposed as <code>MonoString*</code> parameters. This is
different than the way that strings are surfaced in P/Invoke.
<p />
For more information on how the parameters are marshalled, see the
<a href="http://www.mono-project.com/docs/advanced/embedding/">Mono Embedding</a>
page.
<p />
See the <a href="mono-api-methods.html<code>method</code>-desc">Method Description</a>
reference for more information on the format of method descriptions.</div>
</div><!--mapi-description -->
</div><!--height container -->
<h3>P/Invoke with embedded applications</h3>
<p />Unlike internal calls, Platform/Invoke is easier to use and
more portable. It allows you to share code with Windows and
.NET that have a different setup for internal calls to their
own runtime.
<p />Usually P/Invoke declarations reference external libraries
like:
<pre>
[DllImport ("opengl")]
void glBegin (GLEnum mode)
</pre>
<p />Mono extends P/Invoke to support looking up symbols not in
an external library, but looking up those symbols into the
same address space as your program, to do this, use the
special library name "__Internal". This will direct Mono to
lookup the method in your own process.
<p />There are situations where the host operating system does
not support looking up symbols on the process address space.
For situations like this you can use
the <a href="#api:mono_dl_register_library">mono_dl_register_library</a>.
</div>
<h4><a name="api:mono_dl_register_library">mono_dl_register_library</a></h4>
<h3>Data Marshalling</h3>
<p />Managed objects are represented as <tt>MonoObject*</tt>
types. Those objects that the runtime consumes directly have
more specific C definitions (for example strings are of type
<tt>MonoString *</tt>, delegates are of type
<tt>MonoDelegate*</tt> but they are still <tt>MonoObject
*</tt>s).
<p />As of Mono 1.2.x types defined in mscorlib.dll do not have
their fields reordered in any way. But other libraries might
have their fields reordered. In these cases, Managed
structures and objects have the same layout in the C# code as
they do in the unmanaged world.
<p />Structures defined outside corlib must have a specific
StructLayout definition, and have it set as sequential if you
plan on accessing these fields directly from C code.
<p /><b>Important</b> Internal calls do not provide support for
marshalling structures. This means that any API calls that
take a structure (excluding the system types like int32,
int64, etc) must be passed as a pointer, in C# this means
passing the value as a "ref" or "out" parameter.
<h3>Mono Runtime Configuration</h3>
<p />Certain features of the Mono runtime, like DLL mapping, are
available through a configuration file that is loaded at
runtime. The default Mono implementation loads the
configuration file from <tt>$sysconfig/mono/config</tt>
(typically this is <tt>/etc/mono/config</tt>).
<p />See the <tt>mono-config(5)</tt> man page for more details
on what goes in this file.
<p />The following APIs expose this functionality:
<a name="api:mono_config_cleanup"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_config_cleanup</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_config_cleanup (void)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_config_is_server_mode"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_config_is_server_mode</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">mono_bool
mono_config_is_server_mode (void)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_config_parse"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_config_parse</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_config_parse (const char *filename)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>filename</i></td><td> the filename to load the configuration variables from.</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Pass a <code>NULL</code> filename to parse the default config files
(or the file in the <code>MONO_CONFIG</code> env var).</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_config_parse_memory"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_config_parse_memory</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_config_parse_memory (const char *buffer)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>buffer</i></td><td> a pointer to an string XML representation of the configuration</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Parses the configuration from a buffer</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_config_set_server_mode"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_config_set_server_mode</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_config_set_server_mode (mono_bool server_mode)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_config_string_for_assembly_file"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_config_string_for_assembly_file</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">const char *
mono_config_string_for_assembly_file (const char *filename)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_get_config_dir"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_get_config_dir</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">const char*
mono_get_config_dir (void)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_get_machine_config"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_get_machine_config</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">const char *
mono_get_machine_config (void)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_register_machine_config"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_register_machine_config</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_register_machine_config (const char *config_xml)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_set_config_dir"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_set_config_dir</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_set_config_dir (const char *dir)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
Invoked during startup</div>
</div><!--mapi-description -->
</div><!--height container -->
<h3>Advanced Execution Setups</h3>
<p />These are not recommended ways of initializing Mono, they
are done internally by mono_jit_init, but are here to explain
what happens internally.
</div> <!-- class=mapi -->
<a name="api:mono_runtime_exec_managed_code"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_runtime_exec_managed_code</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_runtime_exec_managed_code (MonoDomain *domain,
MonoMainThreadFunc mfunc,
gpointer margs)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>domain</i></td><td> Application domain</td></tr><tr><td><i>main_func</i></td><td> function to invoke from the execution thread</td></tr><tr><td><i>main_args</i></td><td> parameter to the main_func</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Launch a new thread to execute a function
<p />
<i>main_func</i> is called back from the thread with main_args as the
parameter. The callback function is expected to start <code>Main</code>
eventually. This function then waits for all managed threads to
finish.
It is not necessary anymore to execute managed code in a subthread,
so this function should not be used anymore by default: just
execute the code and then call mono_thread_manage().</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_runtime_exec_main"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_runtime_exec_main</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">mono_runtime_exec_main</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_init"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_init</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">MonoDomain*
mono_init (const char *domain_name)
</div>
<p />
<div class="mapi-section">Return value</div>
<div> the initial domain.
</div>
<div class="mapi-section">Description</div>
<div>
<p />
Creates the initial application domain and initializes the mono_defaults
structure.
<p />
This function is guaranteed to not run any IL code.
The runtime is initialized using the default runtime version.
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_init_from_assembly"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_init_from_assembly</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">MonoDomain*
mono_init_from_assembly (const char *domain_name, const char *filename)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>domain_name</i></td><td> name to give to the initial domain</td></tr><tr><td><i>filename</i></td><td> filename to load on startup</td></tr></tbody></table> <div class="mapi-section">Return value</div>
<div> the initial domain.
</div>
<div class="mapi-section">Description</div>
<div>
<p />
Used by the runtime, users should use mono_jit_init instead.
<p />
Creates the initial application domain and initializes the mono_defaults
structure.
This function is guaranteed to not run any IL code.
The runtime is initialized using the runtime version required by the
provided executable. The version is determined by looking at the exe
configuration file and the version PE field)
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_init_version"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_init_version</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">MonoDomain*
mono_init_version (const char *domain_name, const char *version)
</div>
<p />
<div class="mapi-section">Return value</div>
<div> the initial domain.
</div>
<div class="mapi-section">Description</div>
<div>
<p />
Used by the runtime, users should use <code>mono_jit_init</code> instead.
<p />
Creates the initial application domain and initializes the <code>mono_defaults</code>
structure.
<p />
This function is guaranteed to not run any IL code.
The runtime is initialized using the provided rutime version.
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_jit_exec"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_exec</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">int
mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>assembly</i></td><td> reference to an assembly</td></tr><tr><td><i>argc</i></td><td> argument count</td></tr><tr><td><i>argv</i></td><td> argument vector</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Start execution of a program.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_jit_set_aot_mode"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_jit_set_aot_mode</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_jit_set_aot_mode (MonoAotMode mode)
</div>
<p />
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_set_break_policy"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_set_break_policy</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_set_break_policy (MonoBreakPolicyFunc policy_callback)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>policy_callback</i></td><td> the new callback function</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
<p />
Allow embedders to decide whether to actually obey breakpoint instructions
(both break IL instructions and <code>Debugger.Break</code> method calls), for example
to not allow an app to be aborted by a perfectly valid IL opcode when executing
untrusted or semi-trusted code.
<p />
<i>policy_callback</i> will be called every time a break point instruction needs to
be inserted with the method argument being the method that calls <code>Debugger.Break</code>
or has the IL <code>break</code> instruction. The callback should return <code>MONO_BREAK_POLICY_NEVER</code>
if it wants the breakpoint to not be effective in the given method.
<code>MONO_BREAK_POLICY_ALWAYS</code> is the default.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
<a name="api:mono_get_runtime_build_info"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_get_runtime_build_info</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">char*
mono_get_runtime_build_info (void)
</div>
<p />
<div class="mapi-section">Return value</div>
<div> the runtime version + build date in string format.
</div>
<div class="mapi-section">Description</div>
<div>
The returned string is owned by the caller. The returned string
format is <code>VERSION (FULL_VERSION BUILD_DATE)</code> and build date is optional.</div>
</div><!--mapi-description -->
</div><!--height container -->
<h3>Signal Chaining</h3>
</div> <!-- class=mapi -->
<a name="api:mono_set_signal_chaining"></a>
<div class="mapi">
<div class="mapi-entry "><code>mono_set_signal_chaining</code></div>
<div class="mapi-height-container">
<div class="mapi-ptr-container"></div>
<div class="mapi-description">
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_set_signal_chaining (gboolean chain_signals)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
<p />
Enable/disable signal chaining. This should be called before <code>mono_jit_init</code>.
If signal chaining is enabled, the runtime saves the original signal handlers before
installing its own handlers, and calls the original ones in the following cases:
- a <code>SIGSEGV</code> / <code>SIGABRT</code> signal received while executing native (i.e. not JITted) code.
- <code>SIGPROF</code>
- <code>SIGFPE</code>
- <code>SIGQUIT</code>
- <code>SIGUSR2</code>
Signal chaining only works on POSIX platforms.</div>
</div><!--mapi-description -->
</div><!--height container -->
|