Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is necessary to have in AssemblyInfo.cs?

The default AssemblyInfo.cs looks like this:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Foobar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Foobar")]
[assembly: AssemblyCopyright("Copyright ©  2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e8cd5d7d-5fba-4fe1-a753-f0cc6e052bf2")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

What of all this is really necessary? Can I for example remove the Guid and ComVisible if I don't need that, or the AssemblyTrademark as it's just empty anyways?

like image 985
Svish Avatar asked Sep 12 '12 14:09

Svish


People also ask

What does AssemblyInfo CS file consists of?

AssemblyInfo. cs contains information about your assembly, like name, description, version, etc. You can find more details about its content reading the comments that are included in it.

What generates AssemblyInfo CS?

You can generate an assemblyInfo. cs by right clicking the project and chosing properties. In the application tab fill in the details and press save, this will generate the assemblyInfo.

How do I get AssemblyInfo CS go?

It is located under the folder "Properties". AssemblyInfo. cs file also get created, when you create any Web Application project.


2 Answers

This is just metadata - none of it is required as such.

ComVisible and Guid are only needed if you are doing COM interop with the assembly. The other attributes end up as metadata on the DLL (visible through the Version tab of the file properties dialog in Windows Explorer).

You can delete the file and your application will compile just fine, though it will have not metadata and will not be COM visible.

like image 136
Oded Avatar answered Oct 26 '22 12:10

Oded


Really necessary aren't any of the attributes. But it is recommended to use them!

[assembly: AssemblyVersion("1.0.0.0")]

The AssemblyVersion gives a version to the assembly and is used from the CLR to identify an assembly (StrongName). AssemblyFileVersion is only an attribute on the FileDialog.

[assembly: AssemblyInformationalVersion("1.0.0.0")]

You can but there any other version information how you like. Another really nice attribute is the following:

[assembly: SuppressIldasm]

It's suppress to open your assembly in ildasm to look at the IL-Code.

There are many more to write about assembly attributes. May you look at the MSDN for futher information..

like image 39
CodeTherapist Avatar answered Oct 26 '22 12:10

CodeTherapist