5
votes

I'm confused as to whether my Xamarin project is using the Mono framework or the MS .Net one.

If I create a simple console style app using this code to detect if running in Mono but says I'm not.

using System;

namespace ConsoleTest
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Type t = Type.GetType("Mono.Runtime");
            if (t != null)
                Console.WriteLine("You are running with the Mono VM");
            else
                Console.WriteLine("You are running something else");
            Console.ReadLine();
        }
    }
}

The same code running in Xamarin on Mac OSX does say it's running under Mono.

Back on Windows, under my project settings -> Build -> General -> Target Framework is set to "Mono / .NET 4.0". I don't understand, does this mean it will use either Mono or .NET 4.0?

I want to force it to use the Mono framework!

1
All that does is set which version of .Net to reference when compiling (2.0, 3.0, 3.5, 4.0, 4.5, etc). You want to change the "Runtime". There's a setting somewhere in there for it but I don't remember exactly where. - jpobst
Ok. I just had a look through the project & solutions options but couldn't find a setting for it anywhere. :/ - CodeAndCats
Should be Preferences->Projects->.NET Runtimes - Jester
Maybe I'm going about it the wrong way, but I want a sense of confidence that my (non-GUI) app will compile and run on Mac OSX and Linux while I primarily develop in Windows. - CodeAndCats
Thanks Jester, that seems to have done it - put that into a post and I'll mark it as answered :) - CodeAndCats

1 Answers

3
votes

On windows by default XS uses the .NET run time but if you have installed mono framework you can set the default run time to "Mono" and again check output of you code.

You can set default run time to mono from here: On windows => Xamarin Studio => Tools => Options => Projects and .NETRuntimes"