Returning ClickOnce version doesn't work when launching application on startup from the Windows Registry

后端 未结 1 690
感动是毒
感动是毒 2021-01-17 04:04

I\'m using the following code with System.Deployment to return the ClickOnce version of my .NET 3.5 C# application:

public string version
{
             


        
相关标签:
1条回答
  • 2021-01-17 04:41

    I've isolated the problem. I won't pretend to understand exactly how ClickOnce works, but basically, if you launch the executable file directly it won't run in "ClickOnce mode". This means it won't check for updates and won't get the correct version number (since it isn't actually network deployed).

    The best solution I've found so far is to point to the ClickOnce .appref-ms file rather than the .exe file. This file is like a shortcut of sorts, and is in the start menu.

    Here's the code I'm using to get the location of my app's .appref-ms file:

    string allProgramsPath = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
    string shortcutPath = Path.Combine(allProgramsPath, keyName);
    shortcutPath = Path.Combine(shortcutPath, keyName) + ".appref-ms";
    

    And then I combine that with my previous code to set that location in the registry.

    0 讨论(0)
提交回复
热议问题