The AssemblyTitle never changes once set, I want i

2019-07-06 01:46发布

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.

enter image description here

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条回答
放我归山
2楼-- · 2019-07-06 02:28

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
查看更多
登录 后发表回答