在构造函数C#组总成称号 [英] Set Assembly title in constructor c#

查看:129
本文介绍了在构造函数C#组总成称号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想在我的构造函数中设置AssemblyTitle,这样做的原因是因为我有好几个版本的节目,他们都共享相同的AssemblyInfo.cs

我要寻找类似的东西。

  AssemblyTitleAttribute标题=完整版本;
 

但这个不起作用,任何想法?

解决方案

属性是complie时间常数,因此不可能是在构造函数,你有两个选择:

  1. 在一类,它是唯一的完整版本有 [总成:AssemblyTitle(沙盒控制台)] (把它放在你声明命名空间之前)
  2. 使用一个#如果在AssemblyInfo.cs中选择名称并设置您的构建环境来定义你的条件编译符号指令生成属性的标签。

//的AssemblyInfo.cs

//(SNIP)

[总成:AssemblyCopyright(©2011)
[总成:AssemblyTrademark()]
[总成:AssemblyCulture()]
#如果FULL_VERSION
    [总成:AssemblyTitle(XYZ应用程序(完整版))
#其他
    [总成:AssemblyTitle(XYZ应用程序(试行版))
#ENDIF

Basically I would like to set AssemblyTitle in my constructor, the reason of doing this is because I have several versions of program and they all sharing same AssemblyInfo.cs

I am looking for something like that

AssemblyTitleAttribute title = "Full Version";

but this one doesn't work, any ideas?

解决方案

The attribute is a complie time constant so it cannot be "In the constructor", you have two options:

  1. A class that is unique to the full version has [assembly: AssemblyTitle("Sandbox Console")] (put it before you declare the namespace)
  2. Use a #if in the AssemblyInfo.cs to choose the name and set up your build environment to define the directive in your Conditional Compilation Symbols in the Build tab of Properties.

// AssemblyInfo.cs

//(snip)

[assembly: AssemblyCopyright("Copyright ©  2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
#if FULL_VERSION
    [assembly: AssemblyTitle("XYZ App (Full Version)")]
#else
    [assembly: AssemblyTitle("XYZ App (Trial Version)")]
#endif

这篇关于在构造函数C#组总成称号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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