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