Get executing assembly name from referenced DLL in C#

前端 未结 8 869
野性不改
野性不改 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:40

    To get the exact name without versions, etc. use:

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

    Works with .NET v1.1 and later.

提交回复
热议问题