When are Attribute Objects created?

后端 未结 3 1577
一向
一向 2021-02-19 20:42

Since Attributes are really just Metadata attached to assemblies, does that mean that Attribute Objects are only created on request (such as when you call GetCustomAttributes)?

3条回答
  •  耶瑟儿~
    2021-02-19 21:08

    They are created on request.

    For example, if you add some .NET 3.0 attributes to a .NET 2.0 Assembly (e.g. WCF DataContractAttribute), you'll still be able to use the .NET 2.0 Assembly on a machine that doesn't have .NET 3.0 installed, provided you don't have any code that attempts to access the attributes.

提交回复
热议问题