System.Web.PreApplicationStartMethodAttribute 定义为:
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true)]
public sealed class PreApplicationStartMethodAttribute : Attribute
{}
即它允许多次使用(AllowMultiple=true)。但是,如果我尝试将此属性的几种用法添加到我的程序集中:
[assembly: PreApplicationStartMethod(typeof(MyType1), "Start")]
[assembly: PreApplicationStartMethod(typeof(MyType2), "Start")]
我得到编译器错误:
错误 2 重复的“PreApplicationStartMethod”属性
为什么是这样?