Get WPF Project Project Name

I am writing my first WPF application and I am trying to get the name of the project so that 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? Thank you

+6
source share
3 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; 

It also allows another option to get only the name:

 string name = typeof({class name here}).Assembly.GetName().Name; 
+11
source
 Assembly.GetExecutingAssembly().GetName().Name; 
+3
source

Application.ResourceAssembly.FullName will also prevent you from importing System.Reflection.

+1
source

Source: https://habr.com/ru/post/927584/


All Articles