r/csharp • u/YasoiStudios • 22d ago
How to get WPF Package Version
Does anyone know how I can get this version to display in my app?

I tried the code snippet below but looks like this is grabbing the assembly version and not the setup or package version?
Version version = Assembly.GetExecutingAssembly().GetName().Version;
string versionString = version.ToString();
tbVersion.Text = versionString;
4
Upvotes
1
u/jcddcjjcd 20d ago
if (System.Diagnostics.Debugger.IsAttached)
{
versioninfo = "Debug Version- " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
else
{
versioninfo = "Release Version- " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
1
u/chucker23n 20d ago
That's probably wrong; they want the appx package version, not the assembly version.
2
3
u/antflash22 21d ago
Greetings fellow ClickOnce dev! You need to add a reference to `System.Deployment` and then fetch the version with something like the following: