developerweb
developerweb

Reputation: 27

get application version in windows application c#

I use this code for get application version

private string CurrentVersion
    {
        get
        {
            return ApplicationDeployment.IsNetworkDeployed
                   ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
                   : Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }
    }

But in debug mode and when I publish and install application I get 1.0.0.0. How can I fix this problem?

Upvotes: 2

Views: 1868

Answers (1)

Yeldar Kurmangaliyev
Yeldar Kurmangaliyev

Reputation: 34244

In this line of code you are actually trying to obtain an assembly version.

return Assembly.GetExecutingAssembly().GetName().Version.ToString();

You need to set the assembly version in Properties -> Application -> Assembly Information.

Upvotes: 2

Related Questions