アセンブリのバージョンを取得するには
- Assembly.GetExecutionAssemblyでアセンブリ情報を取得する
- 1.で取得したアセンブル情報の GetNmaeメソッドが返す Version情報を参照する
という手順で行います。
以下にコード例を示します。
VBの例
Imports System.Reflection
Module Module1
Sub Main()
Dim asm = Assembly.GetExecutingAssembly()
' アセンブリのバージョンを取得
Dim version = asm.GetName().Version
Console.WriteLine(version)
Console.ReadLine()
End Sub
End Module
C#の例
using System.Reflection;
namespace ReflectionCS
{
class Program
{
static void Main(string[] args)
{
var asm = Assembly.GetExecutingAssembly();
// アセンブリのバージョンを取得
var version = asm.GetName().Version;
Console.WriteLine(version);
Console.ReadLine();
}
}
}
以下に実行例を示します。
Please follow and like us:

コメント