Author Topic: VS2022 ClickOnce version  (Read 1300 times)

0 Members and 1 Guest are viewing this topic.

Offline ArCoNTopic starter

  • Contributor
  • Posts: 24
  • Country: dk
VS2022 ClickOnce version
« on: November 06, 2023, 07:08:19 am »
Hi All

Anyone knows how to get the version from the clickonce into the app somehow?

I have this now, and it does not work. dont know where it gets that version from
this.Text += " " + Assembly.GetEntryAssembly().GetName().Version;

B.R.
 

Offline cgroen

  • Supporter
  • ****
  • Posts: 631
  • Country: dk
    • Carstens personal web
Re: VS2022 ClickOnce version
« Reply #1 on: November 06, 2023, 12:16:48 pm »
This works for me:

      private string getVersion() {
         Assembly assembly = Assembly.GetExecutingAssembly();
         FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
         return fileVersionInfo.ProductVersion;
      }
 

Offline ArCoNTopic starter

  • Contributor
  • Posts: 24
  • Country: dk
Re: VS2022 ClickOnce version
« Reply #2 on: November 06, 2023, 12:27:49 pm »
Thanks for the input. but it still returns 1.0.0 :P
 

Offline cgroen

  • Supporter
  • ****
  • Posts: 631
  • Country: dk
    • Carstens personal web
Re: VS2022 ClickOnce version
« Reply #3 on: November 06, 2023, 01:26:14 pm »
Strange, works in several applications here.
Good luck fixing this, sometimes its not clear what's going on behind the curtains...
 

Offline ArCoNTopic starter

  • Contributor
  • Posts: 24
  • Country: dk
Re: VS2022 ClickOnce version
« Reply #4 on: February 02, 2024, 11:58:50 am »
This is working, when it is published ;)

string versionString = Environment.GetEnvironmentVariable("ClickOnce_CurrentVersion") ?? "0.0.0.0";
Version version = Version.Parse(versionString);
return version;
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf