none
ClickOnce appref-ms question

    Question

  • After installing an application via clickone,in the appref-ms "shortcut file" we have the following:
    URL,Culture,PublicKeyToken and Processor Architecture. This raises a question:

    1) Where is the Target Path ("path to .exe for execution)? I thought it will be in this file. Where does a cickonce application stores this information?
    2) Will it be possible to programmatically create an "appref-ms"?

    Many thanks 
    Monday, September 19, 2011 10:27 AM

Answers

  • Hi,

    If you read the appref-ms file using the following code:

     var shortcutFile = "path to .appref-ms";
                using (StreamReader reader = new StreamReader(shortcutFile, Encoding.Unicode))
                {
                    var result = reader.ReadToEnd();
                }

    you may get the following kind of result:

    http://ServerURL/appName.application#appName.application, Culture=neutral, PublicKeyToken=7446cb71d1187222, processorArchitecture=x86

    From the bold content a definition id will be generated and the system could find the local exe via it. The subsequent process is undocumented unfortunately.

    If you don't know why the exe could be launched without providing system the path of it, please consider the following scenario:

    If you've got a unique id of an application, you can hash it and create a folder with the name of that hash value, put the application in that folder. Then if you could get that unique id again you're able to find the application because the path can be calculated with the unique id.

    Though above is not exactly what ClickOnce does it may shed some light on your concern.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    • Edited by Allen Chen - MSFT Monday, September 26, 2011 9:06 AM
    • Marked as answer by mocasu Monday, September 26, 2011 9:16 AM
    Monday, September 26, 2011 9:04 AM

All replies

  • Hi

    1. The target path is the ClickOnce cache, you can not change it and it is by design!

    2. what is the "appref-ms" here?


    Knowledge will change the destiny.
    Tuesday, September 20, 2011 7:51 AM
  • Hi

    Welcome to the MSDN Forum.

     All ClickOnce applications, whether they are installed locally or hosted online, are stored on the client computer in a ClickOnce application cache.A ClickOnce cache is a family of hidden directories under the Local Settings directory of the current user's Documents and Settings folder.This cache holds all the application's files, including the assemblies, configuration files, application and user settings, and data directory.

    You can see the ClickOnce Overview:

    http://msdn.microsoft.com/en-us/library/267k390a.aspx 

    If you have any questions, please feel free to tell us.

    Best Regards


    Neddy Ren [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by TylerGG Tuesday, September 20, 2011 7:54 AM
    • Unproposed as answer by mocasu Tuesday, September 20, 2011 10:30 AM
    Tuesday, September 20, 2011 7:53 AM
  • Hi tyler,

    Could you please clarify:


    1. From your first statement I understand that you are referring to the the location of the application files (....AppData\Local\Apps\2.0\JWCGZ3K7.HGJ\0NM6EKYH.BVV ....) in here we could have several apps stored

    When the users starts the program, it clicks in the application reference icon of the application, when I look at this file i could not see any target information specifying  the path what .EXE it should run...I would like to know how this is achieved.

    2. I don't understand what you meant by the question. Sorry, english is not my first language. 

    Cheers 


    • Edited by mocasu Tuesday, September 20, 2011 10:31 AM
    Tuesday, September 20, 2011 10:30 AM
  • When the users starts the program, it clicks in the application reference icon of the application, when I look at this file i could not see any target information specifying  the path what .EXE it should run...I would like to know how this is achieved.

    2. I don't understand what you meant by the question. Sorry, english is not my first language. 

    I am not sure what you've set in the project properties. As I create new project and publish it in a UNC path in another computer, I can install the applications and found the all the files, here is the screenshot:


    Maybe you haven't got the correct folder.

    2. sorry for the misunderstanding. Here is the two resolved threads here:

    http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/75d2112c-707c-4051-a5fc-eb51802558bb/
    http://social.msdn.microsoft.com/forums/en-us/winformssetup/thread/94D85523-A02F-4501-95C0-A4291F56F3F3

    Hope it helps :)


    Knowledge will change the destiny.
    Wednesday, September 21, 2011 8:03 AM

  • 1. Ok, so lets take your example...If you open the appref-ms file for that project (ConsoleApplicatoin1.exe), it contains the URL for the updates, some other bits of information but it does not contain the path to where the ConsoleApplication1.exe is, right?... My question is how is the appref-ms file link with the ConsoleApplication1.exe...In another words, when clicking in the appref-ms file, how does it now what .exe to run?
    Hope it makes sense 

    2. I am not trying to make my application start at start up 

    Cheers 
    Wednesday, September 21, 2011 8:36 AM
  • Hi,

    If you read the appref-ms file using the following code:

     var shortcutFile = "path to .appref-ms";
                using (StreamReader reader = new StreamReader(shortcutFile, Encoding.Unicode))
                {
                    var result = reader.ReadToEnd();
                }

    you may get the following kind of result:

    http://ServerURL/appName.application#appName.application, Culture=neutral, PublicKeyToken=7446cb71d1187222, processorArchitecture=x86

    From the bold content a definition id will be generated and the system could find the local exe via it. The subsequent process is undocumented unfortunately.

    If you don't know why the exe could be launched without providing system the path of it, please consider the following scenario:

    If you've got a unique id of an application, you can hash it and create a folder with the name of that hash value, put the application in that folder. Then if you could get that unique id again you're able to find the application because the path can be calculated with the unique id.

    Though above is not exactly what ClickOnce does it may shed some light on your concern.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    • Edited by Allen Chen - MSFT Monday, September 26, 2011 9:06 AM
    • Marked as answer by mocasu Monday, September 26, 2011 9:16 AM
    Monday, September 26, 2011 9:04 AM