![](/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.