Get executing assembly name from referenced DLL in C#

前端 未结 8 880
野性不改
野性不改 2020-12-08 19:20

What is the best way to get the application name (i.e MyApplication.exe) of the executing assembly from a referenced class library in C#?

I need to open the applicat

8条回答
  •  悲&欢浪女
    2020-12-08 19:48

    If you want to read (and display) version number:

      Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
      AssemblyName assname = ass.GetName();
    
      Version ver=assname.Version;
    

    Somewhere in application (ie Title block in a Windows form)

     this.Text = "Your title    Version " + ver;
    

提交回复
热议问题