Reputation: 833
I'm developing a library that tries to get the version number of the application that uses it.
In my test application, when the lib is reading the version number using :
Assembly.GetExecutingAssembly().FullName;
I'm getting the version number of the lib, not the main project.
Is there a simple way to find the version number of the main application, and not the one of my library ?
Thanks.
Upvotes: 1
Views: 7447
Reputation: 26346
To get the version number (1.2.0.0) , use the following code:
string version = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value;
Upvotes: 8
Reputation: 84784
You can use Application.Current
to access the application instance that started the application:
Application.Current.GetType().FullName
Having said that, I don't think have the version number that applies to the application as a whole. For that you'll need to open the WMAppManifest.xml
file and read the version from that. You can get access to the manifest file using:
var manifestUri = new Uri("WMAppManifest.xml", UriKind.Relative);
Stream manifestStream = Application.GetResourceStream(manifestUri);
Upvotes: 7
Reputation: 48279
Assembly.GetEntryAssemlby().FullName;
assuming that this is supported on WP7. If not, try:
typeof(sometype).Assembly.FullName;
on one of types from your main module.
Upvotes: 1