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
554 views
in Technique[技术] by (71.8m points)

c# - 'AssemblyTitle' attribute in the .NET Framework

What is the practical use of the AssemblyTitle attribute? MSDN says that it specifies a description for an assembly and that the assembly title is a friendly name which can include spaces.

Visual Studio asks for the assembly name in the properties window of the project along with the default namespace. There is an AssemblyName attribute but it describes an assembly's unique identity in full (i.e., culture, etc.). I don't see how AssemblyTitle differs from AssemblyProduct.

I used the IL Disassembler to see how Microsoft uses AssemblyTitle. I discovered that in mscorlib.dll, AssemblyTitle, AssemblyProduct and AssemblyDefaultAlias are all set to "mscorlib.dll".

In conclusion, what I really would like to see are practical examples of the use of AssemblyTitle.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

[AssemblyTitle] is a pretty big deal, it is directly visible when you right-click on the assembly and use Properties + Details.

An example to make it more visible. Let's start with this AssemblyInfo.cs file:

[assembly: AssemblyTitle("AssemblyTitle")]
[assembly: AssemblyDescription("AssemblyDescription")]
[assembly: AssemblyConfiguration("AssemblyConfiguration")]
[assembly: AssemblyCompany("AssemblyCompany")]
[assembly: AssemblyProduct("AssemblyProduct")]
[assembly: AssemblyCopyright("AssemblyCopyright")]
[assembly: AssemblyTrademark("AssemblyTrademark")]
[assembly: AssemblyCulture("")]
[assembly: Guid("7da36bdf-39fb-4a4d-b98c-ecefd99b155a")]
[assembly: AssemblyVersion("1.2.3.4")]
[assembly: AssemblyFileVersion("5.6.7.8")]

And look at the properties of the file:

enter image description here

Some annotations to this:

  • Note how [AssemblyDescription] is misleading, it is actually the Title you see in the property sheet.
  • Description, Configuration and Company are not displayed. You probably want to merge the company name into the visible Copyright. Description and Company are actually present in the unmanaged version resource but Windows just doesn't display it.
  • [AssemblyCulture] is special, it is used by satellite assemblies for localization
  • [Guid] is special, it sets the type library guid if you create a [ComVisible] assembly
  • [AssemblyVersion] is extraordinary special, a really big deal in the .NET Framework. That it is not displayed is a major hangup. You can see it in XP, not in later Windows versions. A strong consideration is to make the [AssemblyFileVersion] the same value.
  • The displayed "Product version" is the same as the "File version". That's not great either, you want to add the [AssemblyInformationalVersion] attribute to fix that.

It is quirky, the Windows group and DevDiv didn't always work together well.


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

...