Assembly C# 获取 内容 ProductAttribute version CopyrightAttribute FileVersionAttribute

Assembly C# 获取 内容

            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            Version version = executingAssembly.GetName().Version;

            object[] objectAttrs = executingAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false );
            AssemblyProductAttribute productAttr = (AssemblyProductAttribute)objectAttrs[0];

            objectAttrs = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            AssemblyCopyrightAttribute copyrightAttr = (AssemblyCopyrightAttribute)objectAttrs[0];

            objectAttrs = executingAssembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
            AssemblyFileVersionAttribute fileAttr = (AssemblyFileVersionAttribute)objectAttrs[0];

            string v1 = version.ToString();
            string v2 = copyrightAttr.Copyright;
            string v3 = productAttr.Product;
            string v4 = fileAttr.Version;

posted @ 2012-11-13 10:18  Dzs  阅读(658)  评论(0编辑  收藏  举报