assembly fileset_zarchiver文件管理器

assembly fileset_zarchiver文件管理器AssemblyInfo.cs文件主要用来设定生成的dll程序集的一些常规信息,部分信息可以在引用dll时从属性中直接看到.//标题,属性中不可见//默认值是DLL库名,可以修改成任意值,不影响使用.//注意:千万不要当

assembly fileset_zarchiver文件管理器

AssemblyInfo.cs文件主要用来设定生成的dll程序集的一些常规信息, 部分信息可以在引用dll时

从属性中直接看到.

 

// 标题,属性中不可见
// 默认值是DLL库名,可以修改成任意值,不影响使用.
// 注意: 千万不要当成生成的DLL的名字,生成的DLL的名字是你建立类库时输入的那个名字。
[assembly: AssemblyTitle(“WebApplication01”)]

 

// 描述,属性中可见。
[assembly: AssemblyDescription(“”)]

 

// 文化信息,属性中可见
// 注意:调用DLL时通过assembly的fullname来找,如“ClassLibraryForReadingInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”
// 这里可以赋值,但是会导致找不到DLL. 因为Caller一直是调用“ClassLibraryForReadingInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null” 而此时DLL为”ClassLibraryForReadingInfo, Version=1.0.0.0, Culture=en, PublicKeyToken=null”
提示找不到Assembly,不知道为什么是这样??
[assembly: AssemblyCulture(“”)]

 

//配置文件,不知道有什么用???
[assembly: AssemblyConfiguration(“”)]

 

// 公司,属性中不可见
[assembly: AssemblyCompany(“”)]   

 

// 产品信息
[assembly: AssemblyProduct(“not for commerce”)]

 

// 版权,属性中不可见
[assembly: AssemblyCopyright(“Copyright ©  2009”)]

 

// 商标,属性中不可见
[assembly: AssemblyTrademark(“”)]

 

//程序集是否对COM可见
[assembly: ComVisible(false)]

 

用程序获取Assembly信息
== 根据Type得到Assembly的信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Test1
{

    class AccessAssembly
    {

        static void Main()
        {

            //Change “ClassLibraryForReadingInfo.Class1” to any Class.
            AssemblyInfo<ClassLibraryForReadingInfo.Class1> infoClass = new AssemblyInfo<ClassLibraryForReadingInfo.Class1>();
            Console.WriteLine(“AssemblyFullName : {0}”, infoClass.AssemblyFullName);
            Console.WriteLine(“AssemblyName : {0}”, infoClass.AssemblyName);
            Console.WriteLine(“CodeBase : {0}”, infoClass.CodeBase);
            Console.WriteLine(“Company : {0}”, infoClass.Company);
            Console.WriteLine(“Copyright : {0}”, infoClass.Copyright);
            Console.WriteLine(“Description : {0}”, infoClass.Description);
            Console.WriteLine(“Product : {0}”, infoClass.Product);
            Console.WriteLine(“Title : {0}”, infoClass.Title);
            Console.WriteLine(“Version : {0}”, infoClass.Version);
            Console.WriteLine(“Configration : {0}”, infoClass.Configration);
            Console.WriteLine(“TradeMark : {0}”, infoClass.TradeMark);
            Console.WriteLine(“Culture : {0}”, infoClass.Culture);
            Console.Read();
        }
    }

    public class AssemblyInfo<T>
    {

        private Type myType;

        public AssemblyInfo()
        {

            myType = typeof(T);
        }

        public String AssemblyName
        {

            get
            {

                return myType.Assembly.GetName().Name.ToString();
            }
        }

        public String AssemblyFullName
        {

            get
            {

                return myType.Assembly.GetName().FullName.ToString();
            }
        }

        public String CodeBase
        {

            get
            {

                return myType.Assembly.CodeBase;
            }
        }

        public String Version
        {

            get
            {

                return myType.Assembly.GetName().Version.ToString();
            }
        }

        public String Copyright
        {

            get
            {

                Type att = typeof(AssemblyCopyrightAttribute);
                object[] r = myType.Assembly.GetCustomAttributes(att, false);
                AssemblyCopyrightAttribute copyattr = (AssemblyCopyrightAttribute)r[0];
                return copyattr.Copyright;
            }
        }

        public String Company
        {

            get
            {

                Type att = typeof(AssemblyCompanyAttribute);
                object[] r = myType.Assembly.GetCustomAttributes(att, false);
                AssemblyCompanyAttribute compattr = (AssemblyCompanyAttribute)r[0];
                return compattr.Company;
            }
        }

        public String Configration
        {

            get
            {

                Type att = typeof(AssemblyConfigurationAttribute);
                object[] r = myType.Assembly.GetCustomAttributes(att, false);
                AssemblyConfigurationAttribute configattr = (AssemblyConfigurationAttribute)r[0];
                return configattr.Configuration;
            }
        }

        public string TradeMark
        {

            get
            {

                Type att = typeof(AssemblyTrademarkAttribute);
                object[] r= myType.Assembly.GetCustomAttributes(att, false);
                AssemblyTrademarkAttribute aa = (AssemblyTrademarkAttribute)r[0];
                return aa.Trademark;
            }
        }

        public string Culture
        {

            get
            {

                Type att = typeof(AssemblyCultureAttribute);
                object[] a = myType.Assembly.GetCustomAttributes(att, false);
                if (a.Length > 0)
                {

                    AssemblyCultureAttribute aa = (AssemblyCultureAttribute)a[0];
                    return aa.Culture;
                }
                else
                {

                    return “No value”;
                }
            }
        }

        public String Description
        {

            get
            {

                Type att = typeof(AssemblyDescriptionAttribute);
                object[] r = myType.Assembly.GetCustomAttributes(att, false);
                AssemblyDescriptionAttribute descattr = (AssemblyDescriptionAttribute)r[0];
                return descattr.Description;
            }
        }

        public String Product
        {

            get
            {

                Type att = typeof(AssemblyProductAttribute);
                object[] r = myType.Assembly.GetCustomAttributes(att, false);
                AssemblyProductAttribute prodattr = (AssemblyProductAttribute)r[0];
                return prodattr.Product;
            }
        }

        public String Title
        {

            get
            {

                Type att = typeof(AssemblyTitleAttribute);
                object[] r = myType.Assembly.GetCustomAttributes(att, false);
                AssemblyTitleAttribute titleattr = (AssemblyTitleAttribute)r[0];
                return titleattr.Title;
            }
        }
    }
}

转自:http://blog.sina.com.cn/s/blog_61c4c1f60100eira.html

转载于:https://www.cnblogs.com/jams742003/archive/2009/09/15/1567148.html

今天的文章assembly fileset_zarchiver文件管理器分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/74229.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注