.NET_Framework

DLLに埋め込まれたAssemblyVersionを確認するC#のプログラム。エクスプローラのプロパティからは通常確認することができない。

using System;
using System.Reflection;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace DebugTool
{
    class AssemblyAttributeDumper
    {
        static void Main(string[] args)
        {
            String DLL = args[0];
            Assembly assembly = Assembly.LoadFrom(DLL);
            Console.WriteLine("AssemblyName\n  {0}", assembly.FullName);
            Console.WriteLine("[Attrubutes]");
            // 属性情報を取得する
            foreach (CustomAttributeData attrData in assembly.CustomAttributes)
            {
                Console.WriteLine("  {0}", attrData.AttributeType.Name);
                foreach (CustomAttributeTypedArgument cata in attrData.ConstructorArguments)
                {
                    if (cata.Value.GetType() == typeof(ReadOnlyCollection<CustomAttributeTypedArgument>))
                    {
                        Console.WriteLine("    Array of '{0}':", cata.ArgumentType);
                        foreach (CustomAttributeTypedArgument cataElement in
                            (ReadOnlyCollection<CustomAttributeTypedArgument>)cata.Value)
                        {
                            Console.WriteLine("    Type: '{0}'  Value: '{1}'",
                                cataElement.ArgumentType, cataElement.Value);
                        }
                    }
                    else
                    {
                        Console.WriteLine("    Type: '{0}'  Value: '{1}'",
                            cata.ArgumentType, cata.Value);
                    }
                }
             }
        }
    }
}

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP