![](/img/trans.png)
[英]ASP.NET Core TypeLoadException Could not load type 'System.Web.PreApplicationStartMethodAttribute' from assembly 'System.Web'
[英]System.Web.PreApplicationStartMethodAttribute and ILMerge
假设我需要部署一个程序集(Requirement)。 我将使用ILMerge合并所有程序集。 但我的很多程序集都有PreApplicationStartMethodAttribute(我对所有这些程序集都没有任何控制权)。 ILMerge将创建一个程序集,PreApplicationStartMethodAttribute只允许在程序集中使用一次。 我该怎么办?
(来自评论)
在.NET 4.0中,每个程序集只能指定一次PreApplicationStartMethod
:
PreApplicationStartMethodAttribute类
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class PreApplicationStartMethodAttribute : Attribute
但在.NET 4.5中,单个程序集中的多个属性是可以的:
PreApplicationStartMethodAttribute类
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = true)] public sealed class PreApplicationStartMethodAttribute : Attribute
因此,您可以通过升级到.NET 4.5来避免此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.