Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

c# - What does the assembly keyword mean in the AssemblyInfo.cs. Does it permit to use method inside?

Saw some code snippet inside AssemblyInfo.cs like

[assembly: someattributename]

What does this code mean?

I even saw some method to be used inside assembly, like

[assembly: log4net.Config.XmlConfigurator(Watch=true)]

Is this the attribute anymore?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Attributes are always applied to an element (e.g. a method, property). The "assembly:" prefix means that the attribute (the part you omitted using '*') is applied to the assembly.

Applying Attributes at the Assembly Level If you want to apply an attribute at the assembly level, use the Assembly keyword. The following code shows the AssemblyNameAttribute applied at the assembly level.

using System.Reflection;
[assembly:AssemblyTitle("My Assembly")]

When this attribute is applied, the string "MyAssembly" is placed in the assembly manifest in the metadata portion of the file. You can view the attribute either by using the MSIL Disassembler (Ildasm.exe) or by creating a custom program to retrieve the attribute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...