Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get project name of WPF project [duplicate]

I'm writing my first WPF application, and I'm trying to get the name of the project so I can output it. However, using

Assembly.GetEntryAssembly().GetName()

or

Assembly.GetExecutingAssembly().GetName()

gets me the name as well as the version number(i.e., DataPusher, Version=2.0.466.16967).

Is there a way to get ONLY the assembly name? Thanks.

like image 898
PiousVenom Avatar asked Oct 12 '12 15:10

PiousVenom


1 Answers

string name = Assembly.GetEntryAssembly().GetName().Name;

or

string name = Assembly.GetExecutingAssembly().GetName().Name;

Alternatively, you can get the Assembly object from any known type in the assembly:

Assembly assy = typeof({class name here}).Assembly;

This also allows another option to get the the name only:

string name = typeof({class name here}).Assembly.GetName().Name;
like image 179
Steve Konves Avatar answered Oct 17 '22 05:10

Steve Konves