Skip to content

Monobjc crash on init when using mono framework 3.80 #435

Description

@fvandepitte

We bootstrap our code like this:

public void bootstrap ()
    {
        // Load any required framework
        Console.WriteLine ("AppKit");
        ObjectiveCRuntime.LoadFramework ("AppKit");

        Console.WriteLine ("Foundation");
        ObjectiveCRuntime.LoadFramework ("Foundation");

        Console.WriteLine ("WebKit");
        ObjectiveCRuntime.LoadFramework ("WebKit"); // Required for Proxy Detection with Pac files

        try {
            Console.WriteLine ("Growl");
            ObjectiveCRuntime.LoadFramework ("Growl");
        } catch {
            Console.WriteLine("Failed to load the Growl framework, notifications will not work");
            log.Error("Failed to load Growl framework, notifications will not work");
        }

        // Do the bridge initialization
        Console.WriteLine ("ObjectiveCRuntime.Initialize()");
        ObjectiveCRuntime.Initialize ();

        //make sure the nib files are in place
        Console.WriteLine("Linking nib files to correct localization");
        NibLocalizer.SetLanguage();

        //Run the installer if needed, needs to happen here because we need the AppKit/Foundation framework and have the NSApplication bootstrapped 
        Console.WriteLine ("Checking if installer needs to run...");
        bool blnRunInstaller = Utilities.Installer.RunInstaller ();
        if (blnRunInstaller) {
            Console.WriteLine ("Installer needs to run, exiting client");
            while(true) {
                try {
                    Environment.Exit (0);
                } catch {
                    Console.WriteLine("Exiting client failed!");
                    throw new Exception("Exit client");
                }
            }
        } else {
            Console.WriteLine("No need to run installer");
        }
        Console.WriteLine("ObjectiveCRuntime.Initialize() DONE");
    }

    public void run()
    {
        Console.WriteLine("running from Cocoa");
        log.Warn("running from Cocoa");

        NSApplication.Bootstrap();

        /* Change the working directory to the Resources dir as all resources are located there
         * examples are encfs/vnode watcher/....)
         */
        NSAutoreleasePool objPool = new NSAutoreleasePool();
        System.IO.Directory.SetCurrentDirectory(NSBundle.MainBundle.BundlePath + "/Contents/Resources/"); 
        objPool.Drain();

        Console.WriteLine("Application.nib");
        NSApplication.LoadNib("Application.nib");

        Console.WriteLine("Presentation.GUIManager.show(new FormInfo.StatusIconFormInfo());");
        Presentation.GUIManager.show(new FormInfo.StatusIconFormInfo());

        Console.WriteLine("NSApplication.RunApplication();");
        NSApplication.RunApplication();
    }

And it gives this as result:

AppKit
Foundation
WebKit
Growl
ObjectiveCRuntime.Initialize()
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for NomaDeskClient.Presentation.GUIManager ---> System.ArgumentException: Illegal byte sequence encounted in the input.
Parameter name: string
at (wrapper managed-to-native) Monobjc.ObjectiveCRuntime:BootstrapInternal ()
at Monobjc.ObjectiveCRuntime.Bootstrap () [0x00000] in <filename unknown>:0 
at Monobjc.ObjectiveCRuntime.Initialize () [0x00000] in <filename unknown>:0 
at NomaDeskClient.Presentation.Cocoa.GUIManager.bootstrap () [0x00000] in <filename unknown>:0 
at NomaDeskClient.Presentation.GUIManager..cctor () [0x00000] in <filename unknown>:0 
— End of inner exception stack trace —
at NomaDeskClient.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for NomaDeskClient.Presentation.GUIManager ---> System.ArgumentException: Illegal byte sequence encounted in the input.
Parameter name: string
at (wrapper managed-to-native) Monobjc.ObjectiveCRuntime:BootstrapInternal ()
at Monobjc.ObjectiveCRuntime.Bootstrap () [0x00000] in <filename unknown>:0 
at Monobjc.ObjectiveCRuntime.Initialize () [0x00000] in <filename unknown>:0 
at NomaDeskClient.Presentation.Cocoa.GUIManager.bootstrap () [0x00000] in <filename unknown>:0 
at NomaDeskClient.Presentation.GUIManager..cctor () [0x00000] in <filename unknown>:0 
— End of inner exception stack trace —
at NomaDeskClient.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

We use Mono 3.80 and Monobjc 6.0.2744.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions