Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

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?

like image 799
user705414 Avatar asked Oct 31 '11 13:10

user705414


People also ask

What is assembly keyword in c#?

It means this an attribute on the assembly itself and not on a specific class, method, property etc.

What is assembly info used for?

AssemblyInfo. cs contains information about your assembly, like name, description, version, etc.

What are the attributes of AssemblyInfo CS file?

Assembly identity attributes Three attributes (with a strong name, if applicable) determine the identity of an assembly: name, version, and culture. These attributes form the full name of the assembly and are required when you reference it in code. You can set an assembly's version and culture using attributes.


2 Answers

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.

like image 89
Christian.K Avatar answered Sep 17 '22 17:09

Christian.K


It means this an attribute on the assembly itself and not on a specific class, method, property etc.

like image 29
Rup Avatar answered Sep 16 '22 17:09

Rup