0

假设我需要部署一个程序集(需求)。我将使用 ILMerge 合并所有程序集。但是我的很多程序集都有 PreApplicationStartMethodAttribute(我对所有这些程序集没有任何控制权)。ILMerge 将创建单个程序集,并且 PreApplicationStartMethodAttribute 在程序集中只允许一次。我应该怎么办?

4

1 回答 1

2

(from the comments)

In .NET 4.0, PreApplicationStartMethod can only be specified once per assembly:

PreApplicationStartMethodAttribute Class

[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class PreApplicationStartMethodAttribute : Attribute

but in .NET 4.5, multiple attributes in a single assembly are okay:

PreApplicationStartMethodAttribute Class

[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class PreApplicationStartMethodAttribute : Attribute

so you can avoid the problem by upgrading to .NET 4.5.

于 2013-09-28T12:45:52.070 回答