By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,180 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,180 IT Pros & Developers. It's quick & easy.

application name

P: n/a
how to get the name of a running application using C#

e.g. if i have 20 dll files and my application name is MyGreatApplication
then how to get the name "MyGreatApplication" at runtime?

thx in adv.
c
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Chang

Have a look at the Application.ProductName attribute. Something like this:

/* ******************************* */
static void Main()
{
string appName = Application.ProductName;
Application.Run(new MyFirstForm());
}
/* ******************************* */

regards
roy fine
"Chang" <po******@hotmail.com> wrote in message
news:OF****************@TK2MSFTNGP09.phx.gbl...
how to get the name of a running application using C#

e.g. if i have 20 dll files and my application name is MyGreatApplication
then how to get the name "MyGreatApplication" at runtime?

thx in adv.
c

Nov 16 '05 #2

P: n/a
The ProductName is linked to several different code-paths including attributes
and/or the type
that contains the entry point for the executable. Because you can change the
name through the
resources, you may or may not want to simply use the entry point type.

Assembly main = Assembly.GetEntryAssembly();
if ( main != null ) { return main.EntryPoint.ReflectedType; }

That'll give you the type hosting the entry point and should be very stable.
Unless you often
change class names.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Chang

Have a look at the Application.ProductName attribute. Something like this:

/* ******************************* */
static void Main()
{
string appName = Application.ProductName;
Application.Run(new MyFirstForm());
}
/* ******************************* */

regards
roy fine
"Chang" <po******@hotmail.com> wrote in message
news:OF****************@TK2MSFTNGP09.phx.gbl...
how to get the name of a running application using C#

e.g. if i have 20 dll files and my application name is MyGreatApplication
then how to get the name "MyGreatApplication" at runtime?

thx in adv.
c


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.