Reputation: 16389
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?
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.
Upvotes: 1
Views: 2487
Reputation: 23898
Use Assembly.GetEntryAssembly()
rather than Assembly.GetExecutingAssembly()
to get the entry (i.e. EXE) rather than the current (i.e. DLL).
Upvotes: 3