开发者

.NET/Mono framework targeting

Assume I have 2 machines, one machine with MS windows with .NET 4.0 and the other begin a linux ma开发者_运维知识库chine 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?


ad Question 1: you should expect the version of the Runtime, not of Mono


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;
    }
  } 
}


For Question 2: You can default runtime to mono on windows environment for Xamarin studio.

You can mono run time from here:

Xamarin Studio => Tools => Options => Projects => .NET Runtimes => Add (add mono here)

and mark mono as default runtime.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜