Question

In the Control Panel applet for customizing tray icons, the application's name is shown. In a WinForms application, this name may be changed with the AssemblyTitle value at compile time, as shown in the image.

enter image description here

Is it possible to change this value at runtime, perhaps with a form property or some other method?

Was it helpful?

Solution

Like you said, the name shown in this dialog is the name of your program as given by the executable file. In the world of .NET, it's exposed as the AssemblyTitle attribute.

But that's read-only at run-time because it gets compiled directly into your executable, both as managed metadata and also unmanaged Win32 resource data. There is no way to change it without recompiling.

So the simple answer to your question is no.

But I really can't figure out what you're trying to accomplish here, much less why. You said this in response to Robert Harvey's question:

I am trying to brand and localize that value. I'd rather it be defined as a configuration option than require me to change my build process.

There is a big difference between a localized resource and a run-time configuration option. You can still localize the value at compile-time, but it will require some changes to your build process. I don't know why this is a big deal if you really need this. Changing your build process one time is way easier than writing and maintaining code that dynamically modifies your executable at run-time.

See these questions for details on how you might set about accomplishing this:

Of course, I'd be remiss if I didn't also point out that localizing the name of your application is a very weird thing to do. If I had an application that was called "Text Editor" in English, I wouldn't want the name to be "Textredigerare" in the Swedish version. That lack of consistency destroys my branding, not improves it. Unless you're creating an operating system with a bunch of utility programs, users know your program by its name. Pick a single name—any language—and stick with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top