Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...