Click here to Skip to main content
15,892,804 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have created a program with Visual Studio 2010 and have set a program description from within Visual Studio. I go under Project Properties, Application, Assembly Information then type in a Description and when the program compiles and I check the executable, it does not display my product description.. How can I get this to work??
Thanks in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 15-Aug-11 21:20pm    
Nothing will "display" for you until you do it by yourself. I provided a complete step-by-step solution for you, please see.
--SA

Why just Description? Look at all the assembly attributes; you could have them auto-generated and found in your file "AssemblyInfo.vb". There are AssemblyCompanyAttribute, AssemblyCopyrightAttribute and so on — see http://msdn.microsoft.com/en-us/library/ms973231.aspx[^].

You can retrieve all the values of these attributes and use them in your application; for example, you can present some of this information in your "About" dialog; you can also use some of them in text messages; I usually use AssemblyProductAttribute (it is used by the property System.Windows.Forms.Application.ProductName).

Look at the class definitions for all these attributes: they have AttributeTargets.Assembly; it is defined by the attribute AttributeUsageAttribute applied to other attributes. So, you first need to get the instance of the Assembly of your code. You can use System.Reflection.Assembly.GetCallingAssembly, System.Reflection.Assembly.GetExecutingAssembly or System.Reflection.Assembly.GetEntryAssembly, see http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx[^].

In most cases, I'll recommend to use GetEntryAssembly, as usually you need to retrieve the assembly attributes of the assembly used as a main application assembly, not one of the class libraries (however, you can get assembly information for all of the assemblies used in your solution(s)). Using this method allows you to use the code retrieving assembly information in some class library in a separate universal assembly and in this way re-use this code for different assemblies, getting different results depending on the assembly having the application entry point ("entry assembly").

When you got an instance of the assembly, use the method System.Reflection.Assembly.GetCustomAttributes(Type, Boolean) for each of the attribute types you used in your "AssemblyInfo.vb", see http://msdn.microsoft.com/en-us/library/88d17d13.aspx[^]. It will return the array of attributes (possibly empty), but this array will be of length 1 (or 0), so you need and can get only one attribute instance per attribute type. You will need to type cast the result to the same attribute type you used in the call to System.Reflection.Assembly.GetCustomAttributes(Type, Boolean). Each of the attribute types gives you access to the value you used for application of the attributes to your assembly in your file "AssemblyInfo.vb".

This is the complete solution. Just do it.

—SA
 
Share this answer
 
v2
Comments
NY Andrew 15-Aug-11 21:52pm    
Well first off thank you for the EXTREMELY detailed answer I have looked in to everything you mentioned, but when I open the AssemblyInfo.vb, it displays my description just the way I entered it and yet it is still not applying the description to my executable. Everything else has worked, the product name, version, and copyright, etc. It is putting the Program Name under the Description also for some odd reason.
In AssemblyInfo add this attribute
C#
[assembly: AssemblyDescription("Hello Sample Comments")]


After compilation you can see these in version tab of properties executable under comments section.
 
Share this answer
 
Comments
NY Andrew 15-Aug-11 22:34pm    
That's exactly what I have already..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900