[Mono-dev] Embedded Mono and System.Diagnostics.Process

Mike Hull mike.hull at coversant.net
Tue Dec 20 19:40:40 EST 2005


Hey Guys,

I have a C# application that runs inside of a C daemon.  It does not 
show up when I call System.Diagnostics.Process.GetProcesses();   I'm 
trying to avoid just using a lockfile.pid... 

Do I need to do something else to get this to work?

void main_thread_handler(gpointer userdata)
{
    MonoAssembly *assembly;
    MainThreadArgs *mainthreadargs = (MainThreadArgs *) userdata;

    /* load the server daemon assembly */
    assembly = 
mono_domain_assembly_open(mainthreadargs->domain,"Coversant.SoapBox.Server.Daemon.exe");
    if (!assembly) exit(EXIT_ERRORLOADINGASSEMBLY);

    /* execute daemon.exe's static entry point */
    mono_jit_exec (mainthreadargs->domain, assembly, 
mainthreadargs->argc, mainthreadargs->argv);
}

int main(int argc, char* argv[])
{
    MonoDomain *domain;
    int retval;

    mono_set_defaults(0, mono_parse_default_optimizations(NULL));

    /* jit the daemon */
    domain = mono_jit_init ("Coversant.SoapBox.Server.Daemon.exe");

    /* set the stuff that the main thread needs to know */
    MainThreadArgs mainargs;
    mainargs.domain = domain;
    mainargs.argc = argc;
    mainargs.argv = argv;

    /* parse config */
    mono_config_parse(NULL);

    /* transfer control to mono */
    mono_runtime_exec_managed_code(domain, main_thread_handler, &mainargs);

    /* get exit code from mono */
    retval = mono_environment_exitcode_get ();

    mono_jit_cleanup (domain);
    return retval;
}

Thanks,
-- 
Mike Hull
Coversant, Inc.
Leader in XMPP Instant Messaging



More information about the Mono-devel-list mailing list