1

I have a Windows WPF application which compiles to "MyApp.exe". This application references my DLL named "MyDll.dll". In DLL, I have following function:

public string GetFileDescription()
{
    System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
    return fileVersionInfo.FileDescription;
}

This function supposed to read file description of the executable. But, it is returning same of DLL instead.

If I copy the function to application, it just works fine. But the function should stay in DLL.

How to get assembly information of executable from the referenced dll?

References:

I read multiple questions (including this) on Stack Overflow but none of it involves DLL. This question is about executable name; I want executable file description.

Community
  • 1
  • 1
Amit Joshi
  • 15,448
  • 21
  • 77
  • 141

1 Answers1

3

Use Assembly.GetEntryAssembly() rather than Assembly.GetExecutingAssembly() to get the entry (i.e. EXE) rather than the current (i.e. DLL).

mjwills
  • 23,389
  • 6
  • 40
  • 63