Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix MissingMethodException during Content.Load<Texture2D> in Xamarin Studio on MacOS X?

I'm trying to create a simple program with MonoGame in Xamarin Studio 4.0.10 (build 5). But when I try to load some textures using Content.Load method, I receive an exception System.MissingMethodException with a message

Method not found: 'MonoMac.AppKit.NSImage.AsCGImage'.

The actual lines of code I am using are:

protected override void LoadContent()
{
    //some stuff here

    Texture2D freezeTexts = new Texture2D[5];
    for (int i = 0; i < 5; i++) {
        freezeTexts[i] = Content.Load<Texture2D>("freeze"+i); // exception here
    }

    //some other stuff here
}

I did some googling and found out that this happens because of some API changes, which Xamarin Studio haven't yet implemented (at least that's what I understood). So my question is: How can I fix this problem?

like image 232
Anton Guryanov Avatar asked Sep 23 '13 19:09

Anton Guryanov


1 Answers

You can compile monomac from the latest source, to bring the API up to date.

It's pretty straightforward - this blog has some good instructions.

EDIT

It seems you need to go back in time with monomac to get a version compatible with the current release of MonoGame (which is pretty old - 3.0.1 was released on March 6th 2013).

It might be better to compile MonoGame itself from source. I managed to do this by forking their repo and compiling the MonoGame.Framework.MacOS solution.

Referencing the assembly this produces in place of the released MonoGame.Framework.dll allows my test app to build and launch.

like image 171
TheNextman Avatar answered Nov 15 '22 03:11

TheNextman