Search code examples
.netwindowslinuxframeworksmono

.NET/Mono framework targeting


Assume I have 2 machines, one machine with MS windows with .NET 4.0 and the other begin a linux machine with Mono 2.10.1
Now I create a command line application on the respective machines that will output the installed framework version using:

Console.WriteLine(Environment.Version);  

Question 1

Is my assumption correct that the following should be displayed:
Windows : 4.0.30319.1
Linux : 2.10.1 (or something similar??)

Question 2
Assuming we have both mono and ms.net installed on a windows machine, is there a way to specify that an exe must run on the mono framework in windows? (perhaps a config file?)

Question 3
If I compile a (simple) mono application on a linux machine, will that compiled exe work on a windows machine with only ms.net installed?


Solution

  • Update

    • Question 1 (test.cs below[1]), tested on linux:

    .

    mono.2.6.7 $ ./test.exe 
    2.0.50727.1433
    $ source custom/MONO/devenv.sh 
    mono.2.11 $ dmcs test.cs
    mono.2.11 $ ./test.exe 
    WARNING: The runtime version supported by this application is unavailable.
    Using default runtime: v1.1.4322
    1.1.4322.2032
    mono.2.11 $ mono ./test.exe 
    4.0.30319.1
    mono.2.11 $ 
    
    • Question 2

      You could make a batch file to invoke mono.exe myapplication. Look in %PROGRAMFILES%\Mono 2.10\bin for plenty examples

    • Question 3 Yup

    For compatibility check the other way around (check for implementation stubs, missing P/Invoke functionality etc.) there is the MoMa tool


    test.cs

    using System;
    
    namespace X 
    { 
      class Y 
      {
        public static int Main(string[] args)
        {
          Console.WriteLine(Environment.Version);
          return 0;
        }
      } 
    }