5

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?

Anton Guryanov
  • 12,109
  • 1
  • 15
  • 16

1 Answers1

6

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.

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • I followed the instructions to compile MonoMac.dll, then I added this as a reference to a project instead of existing MonoMac, but I still have the same exception. I hope I just need to find a specific commit to build? – Anton Guryanov Sep 23 '13 at 21:00
  • @AntonGuryanov See my edit. I don't know if this is the recommended solution or not, but it should get you up and running – TheNextman Sep 24 '13 at 14:53
  • 1
    Thanks, now it is working! Just to mention, it is unnecessary to fork their repo, just clone and build. – Anton Guryanov Sep 24 '13 at 15:31