Force Xamarin to use Mono on Windows

2019-04-29 11:16发布

问题:

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:

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"