+ num_main_args = 0;
+ main_args = NULL;
+}
+
+/**
+ * mono_runtime_set_main_args:
+ * @argc: number of arguments from the command line
+ * @argv: array of strings from the command line
+ *
+ * Set the command line arguments from an embedding application that doesn't otherwise call
+ * mono_runtime_run_main ().
+ */
+int
+mono_runtime_set_main_args (int argc, char* argv[])
+{
+ int i;
+
+ free_main_args ();
+ main_args = g_new0 (char*, argc);
+ num_main_args = argc;
+
+ for (i = 0; i < argc; ++i) {
+ gchar *utf8_arg;
+
+ utf8_arg = mono_utf8_from_external (argv[i]);
+ if (utf8_arg == NULL) {
+ g_print ("\nCannot determine the text encoding for argument %d (%s).\n", i, argv [i]);
+ g_print ("Please add the correct encoding to MONO_EXTERNAL_ENCODINGS and try again.\n");
+ exit (-1);
+ }
+
+ main_args [i] = utf8_arg;
+ }
+
+ return 0;