

using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace bitWalk
{
class VerTest
{
public static void Main (string[] args)
{
string clrVersionBuildtime = Assembly.GetExecutingAssembly ().ImageRuntimeVersion;
Console.WriteLine ("built CLR version: " + clrVersionBuildtime);
string clrVersionRuntime = RuntimeEnvironment.GetSystemVersion();
Console.WriteLine ("runtime CLR version: " + clrVersionRuntime);
}
}
}
プログラム名は VerTest.exe です。Linux の端末エミュレータ上で実行してみると、CLR のバージョンはどちらも v2.0.50727 でした。

Wine 上だと、実行バージョンが変わるかもしれないと期待して試してみましたが、両方とも v2.0.50727 でした。

それでは Windows 上であれば、と期待して実行してみましたが、結果はやはり同じ v2.0.50727 です。

なんとなく納得できないので、今度は、Windows XP 上の Visual Studio 2010 Express で同じソースを VerTest_VS.exe としてコンパイルして実行してみました。Windows 上では v4.0.30319 と表示されています。

Linux / Mono 上で実行すると、今度は確かに実行 CLR のバージョンが変わりました (v1.1.4322)。

Mono でコンパイルしたプログラムで直接確認できませんでしたが、機能的には確認できたので、とりあえず納得です。
参考サイト
[1] @IT:.NET TIPS ビルド時および実行時のCLRバージョンを取得するには? - C# VB.NET
[2] @IT:.NET TIPS サイド・バイ・サイドによりCLRバージョンを指定するには?
0 件のコメント:
コメントを投稿