Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# AssemblyInfo.cs "bug"

Can someone explain how to make assembly info correctly?

This is my AssemblyInfo.cs:

[assembly: AssemblyTitle("Title")]
[assembly: AssemblyDescription("Description")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mycompany")]
[assembly: AssemblyProduct("ProductName")]
[assembly: AssemblyCopyright("Copyright ©")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(true)]

[assembly: Guid("xxxxxx-xxxxx-xxxxx")]    

[assembly: AssemblyVersion("1.0")]
[assembly: AssemblyFileVersion("1.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]

and this is how it is shown in properties window:Details

You can see that Description and Language is not same as in AssemblyInfo.cs.

Also something is wrong with AssemblyCompany because when I open startup keys in ccleaner, company field is empty for my program...enter image description here

What am I doing wrong?

like image 792
mgulan Avatar asked Nov 18 '13 13:11

mgulan


1 Answers

Windows doesn't know beans about managed assembly attributes. What you actually see is an unmanaged resource that's embedded in the assembly. The C# compiler auto-generates it from the attribute values in your AssemblyInfo.cs file. You can see it yourself with File + Open + File, select your .dll or .exe file. Double-clicking the Version.1 resource opens the unmanaged resource editor, the one you use in a C++ project.

The mapping from managed attributes to that unmanaged version resource is imperfect. Note for example that you cannot see the [AssemblyVersion] attribute value. Extremely important in .NET, Windows only displays the [AssemblyFileVersion] attribute value.

And culture is certainly such an impedance mismatch. A .NET assembly that contains code always has AssemblyName.CultureName set to "*". Only satellite assemblies have a culture. And title vs description, the unmanaged version resource has only one field that qualifies, they selected [AssemblyTitle] to map to that field.

You can create your own unmanaged version resource with a resource script, compile it with rc.exe. You use Project + Properties, Application tab, Resource file radio button to tell the C# compiler about it. You are unlikely to enjoy it much, constantly updating and recompiling the resource script to keep the version number in sync is going to wear you out quickly unless you can automate that.

like image 92
Hans Passant Avatar answered Sep 23 '22 21:09

Hans Passant