The AssemblyTitle never changes once set, I want it to be changed per configuration

元气小坏坏 提交于 2019-12-10 17:45:25

问题


I would like to change the text shown in the screenshot below based on the Product name. I know, the text is taken from Assembly.Title property which is a read only property and so can not be changed at runtime. So how do I change it at compile time? We sell the application to multiple customers and the name of the application should change per customer. We have a configurations for each customer. So at build time, Assembly title should be selected as per the configuration.

Any suggestion how to solve this?

Update:

I tried some of the suggestions given in the comments and I found following:

After I set the text using the assembly info popup from project properties or by changing it directly in the AssemblyInfo.cs file, it is shown correctly in the taskbar.

If I change it again, changed text is not shown in the taskbar ie. it shows all the time the text which was set at FIRST time.

I tried deleting files, even restarting the system, but it didn't help.

Then I renamed the file (i.e. exe file) and then it showed correctly the changed text.

If I rename it back to original name, it shows the first set text.

What could be the reasons?


回答1:


In AssemblyInfo.cs (under Properties in a VisualStudio project), you'll find the assembly title specified in an attribute like this:

[assembly: AssemblyTitle("MyAssembly")]

You should be able to wrap this with compiler constants:

#if SOME_MODE
    [assembly: AssemblyTitle("SomeName")]
#else
    [assembly: AssemblyTitle("ADifferentName")]
#endif


来源:https://stackoverflow.com/questions/21380435/the-assemblytitle-never-changes-once-set-i-want-it-to-be-changed-per-configurat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!