程序说明未出现在.exe中 [英] Program Description not appearing on .exe

查看:127
本文介绍了程序说明未出现在.exe中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Visual Studio 2010创建了一个程序,并在Visual Studio中设置了程序描述.我进入项目属性",应用程序",程序集信息",然后键入描述",然后在编译程序并检查可执行文件时,它不显示我的产品描述. 在此先感谢.

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.

推荐答案

为什么只是Description?查看所有程序集属性;您可以让它们自动生成并在文件"AssemblyInfo.vb"中找到.有AssemblyCompanyAttributeAssemblyCopyrightAttribute等,请参见 http://msdn.microsoft.com/zh-cn/library/ms973231.aspx [ ^ ].

您可以检索这些属性的所有值,并在您的应用程序中使用它们.例如,您可以在关于"对话框中显示某些信息;您也可以在短信中使用其中一些;我通常使用AssemblyProductAttribute(由属性System.Windows.Forms.Application.ProductName使用).

查看所有这些属性的类定义:它们具有AttributeTargets.Assembly;它由应用于其他属性的属性AttributeUsageAttribute定义.因此,您首先需要获取代码的Assembly实例.您可以使用System.Reflection.Assembly.GetCallingAssemblySystem.Reflection.Assembly.GetExecutingAssemblySystem.Reflection.Assembly.GetEntryAssembly,请参见 http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx [
当您获得程序集的实例时,对在"AssemblyInfo.vb"中使用的每种属性类型使用方法System.Reflection.Assembly.GetCustomAttributes(Type, Boolean),请参见
http://msdn.microsoft.com/en-us/library/88d17d13.aspx [
这是完整的解决方案.就做吧.

—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


在AssemblyInfo中添加以下属性
In AssemblyInfo add this attribute
[assembly: AssemblyDescription("Hello Sample Comments")]



编译后,您可以在注释"部分下的可执行文件属性的版本"选项卡中看到它们.



After compilation you can see these in version tab of properties executable under comments section.


这篇关于程序说明未出现在.exe中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆