Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have a dll, within that dll, I want to get the assembly version of the exe that is referencing it and using classes in that dll. I want this for tracking purposes.

Currently these both only return the assembly version of the dll, not the exe referencing it.

C#
string assembly = Assembly.GetExecutingAssembly().GetName().Version.ToString();
string callingassembly = Assembly.GetCallingAssembly().GetName().Name;
string callingversion = Assembly.GetCallingAssembly().GetName().Version.ToString();


I can also get the dll version from the calling exe using this, but I want the opposite:

Assembly.GetAssembly(this._variable.GetType()).GetName().Version);


where _variable is an object that is declared in the exe, of a type contained in the dll.
Posted

1 solution

Have you looked at GetEntryAssembly[^]
 
Share this answer
 
Comments
Ron Beyer 9-Aug-13 14:54pm    
+5, entry assembly is the right way to get it.
wizardzz 9-Aug-13 15:01pm    
Thanks Griff, totally overlooked! Not sure why, but I thought that was something else! Face meet palm.
OriginalGriff 9-Aug-13 15:08pm    
There are just soooooo many methods in .NET, I come across "new" ones every damn day! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900