2

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?

7
  • Did you set the version? (Goto Project-properties-publish !) Commented Jul 2, 2015 at 8:35
  • yes , i set version in project propertices - > publish -> publish version Commented Jul 2, 2015 at 8:36
  • 4
    @developerweb Have you set it in Properties -> Application -> Assembly Information? Commented Jul 2, 2015 at 8:36
  • Is 'Increment when publishing'`checked? Commented Jul 2, 2015 at 8:37
  • @YeldarKurmangaliyev , oh , i don't set this file,its necessary?because i always work whit publish section in project propertices Commented Jul 2, 2015 at 8:39

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.