[Mono-osx] Please help: embedding Mono in a Cocoa application

gevik g.babakhani at truesoftware.nl
Fri Aug 21 06:19:09 EDT 2009


Hi, 
  
So far I am able to compile and link mono with my cocoa application. 
I have a simple window with a button. After clicking the button I am trying
to execute the code that is provided in "mono/samples/embed/teste.c". 

I also have a HelloWorld.cs=>HelloWorld.exe application. 

The first time I click on the button everything goes OK and the
HelloWorld.exe gets executed. 
The second time I click on the button, the cocoa application crashes. Has
anyone encountered a similar problem? 

There is also nothing in the debug window about the crash. 

Any advice? 

here is my sample code: 

---------------------------------------------------------------------------------- 
-(IBAction) testButton:(id)sender 
{ 
        MonoDomain *domain; 
        MonoAssembly *assembly; 
        
        mono_config_parse ("config"); 
        NSString *file = [NSString
stringWithString:@"/Users/gevik/mono2/tests/HelloWorld.exe"]; 
        domain = mono_jit_init ([file UTF8String]); 
        
        if(!domain) 
        { 
                NSLog(@"Domain load error.."); 
                return; 
        } 
        
        assembly = mono_domain_assembly_open (domain, [file UTF8String]); 
        if(!assembly) 
        { 
                NSLog(@"Assembly load error.."); 
                return; 
        } 
        
        NSString *exeName = [[NSBundle mainBundle] executablePath]; 

        const char* argv[] = { 
                [exeName UTF8String] 
        }; 
        
        NSLog(@"%@",exeName); 
        mono_jit_exec (domain, assembly, 1, (char**)argv);	
        mono_jit_cleanup (domain); 
} 
-- 
View this message in context: http://www.nabble.com/Please-help%3A-embedding-Mono-in-a-Cocoa-application-tp25076141p25076141.html
Sent from the Mono - OSX mailing list archive at Nabble.com.



More information about the Mono-osx mailing list