在.NET 4(.5)中有这样的惊人Attribute:PreApplicationStartMethodAttribute我想在SharePoint 2013中使用它,所以我不必直接app_start在global.asax文件中编辑方法.
由于SP2013运行的是正确版本的.NET,我认为这个属性可以正常工作......但似乎并非如此.
有没有人想出如何使用它?或解释为什么它不能工作?
小更新:在我看到的system.web dll中,PreApplicationStartMethodAttribute由下面的类调用.
// System.Web.Compilation.BuildManager
internal static ICollection<MethodInfo> GetPreStartInitMethodsFromAssemblyCollection(IEnumerable<Assembly> assemblies, bool buildingFromCache)
{
List<MethodInfo> list = new List<MethodInfo>();
foreach (Assembly current in assemblies)
{
PreApplicationStartMethodAttribute[] array = null;
try
{
array = (PreApplicationStartMethodAttribute[])current.GetCustomAttributes(typeof(PreApplicationStartMethodAttribute), true);
}
catch
{
}
if (array == null || !array.Any<PreApplicationStartMethodAttribute>())
{
if (buildingFromCache)
{
return null;
}
}
else
{
PreApplicationStartMethodAttribute[] array2 = array;
for (int i = 0; i < …Run Code Online (Sandbox Code Playgroud)