What do you need to have in AssemblyInfo.cs?

By 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")] 

Which of these is really necessary? Can I, for example, remove Guid and ComVisible, if I do not need it, or AssemblyTrademark, since it is just empty anyway?

+6
source share
2 answers

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

ComVisible and Guid are only necessary if you are performing a COM interaction with the assembly. Other attributes fall into the metadata in the DLL (visible through the Version tab of the file properties dialog box in Windows Explorer).

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

+9
source

In reality, not some attributes are needed. But it is recommended to use them!

 [assembly: AssemblyVersion("1.0.0.0")] 

AssemblyVersion provides the assembly version and is used from the CLR to identify the assembly (StrongName). AssemblyFileVersion is only an attribute in FileDialog.

 [assembly: AssemblyInformationalVersion("1.0.0.0")] 

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

 [assembly: SuppressIldasm] 

It suppresses to open the assembly in ildasm to view the IL code.

There are many more articles about assembly attributes. You can view MSDN for further information.

+3
source

Source: https://habr.com/ru/post/925226/


All Articles