Programmatically install setup.exe from ClickOnce deploy location when client is updating. I am already handling the update checking/instaling programmatically. Updating deployment manifest for a ClickOnce application programmatically results in missing element, required in 4.0 Ask Question 5.
Introduction ClickOnce applications do a great job of isolating applications from each other. This was done for two reasons, security and maintainability. Firstly, it allows for greater security since the.NET Framework manages security via code access policies. Secondly, it increases maintainability by preventing the problems with 'DLL hell'. But this does pose a problem when one wants to launch the application. While it is installed on the hard drive, the framework installs it in different locations for every user. Microsoft solved this problem by creating a special type of shortcut, called an 'application reference' that is used in the start menu when a ClickOnce application is installed locally.
Great, now we can launch an application from the start menu, but what if we want to launch it from another application? To answer this problem, I started where many of you are thinking. I will just use the URL to the.application manifest file on the server. Just do a System.Diagnostics.Process.Start on the URL and I am good to go. While this will work fine in an always connected scenario, it doesn't work if the application needs to run in offline mode.
For those applications, I suggest doing a little bit of thievery. Since the application reference (.appref-ms) that is created in the start menu will launch the application (if it is installed) for any user on any computer (with the.NET Framework 2.0 installed), all we need to do is steal it out of the start menu and embed it in our launching application. This technique is useful for applications that run in an online/offline mode. For online only application, I suggest using just the URL. Shawn is an Orlando FL based developer and president of the Orlando.NET Users Group (Currently he is doing intranet & smart client development at a local fortune 500 company and teaches at the Florida Institute of Technology. Shawn started his career at his family business in Port St. Lucie Florida while working on his undergraduate degree in Business Administration at the University of Central Florida and after a year off Shawn moved to Orlando to pursue a Masters degree in Management Information Systems at UCF.
Before graduating Shawn worked as an intern at the company he currently works full time for. Currently Shawn is working on a second Masters degree in Computer Science at FIT. Besides his work, Shawn enjoys volunteering with local organizations. Member 4721536 15-Apr-08 1:46 15-Apr-08 1:46 install the application on a test machine from it's deployment url.
Open the application.reference file in the start menu using notepad, i.e: Culture=neutral, PublicKeyToken=59a31195e50ec799, processorArchitecture=msil You can jam that string into.any. programming language to start the process. For example: C: ShellExecuteA(0,'open','Culture=neutral, PublicKeyToken=59a31195e50ec799, processorArchitecture=msil',NULL,NULL,SWHIDE); VB6: Shell('Culture=neutral, PublicKeyToken=59a31195e50ec799, processorArchitecture=msil') etc etc. Okay I got you now and it works pretty well. Might be clearer if you altered the article to indicate that the application reference is the shortcut found in C: Documents and Settings username Start Menu Programs Manfacturer Name ApplicationName.appref-ms The.appref-ms doesn't show and being a new file type on the system some might not have become aquainted with this type of shortcut/link file. Also one needs to be sure to add a reference to System.Diagnostics to use Process.Start(@'path to AppRef.appref-ms'); I used 'using System.Diagnostic;' in the form.cs file.
Works well, cool idea I need to see how it can be further extended. Thanks - modified at 8:07 Thursday 28th September, 2006. BillWoodruff 1-Jun-06 10:09 1-Jun-06 10:09 I appreciate your sharing your work, but I am left with a real sense of curiousity about what are the advantages or uses of launching a ClickOnce application in this way from another ClickOnce application. If you could say a little more about why you developed this, and what class of problems it solves, or what it facilitates, or makes possible, that would be appreciated. Best, Bill 'The greater the social and cultural distances between people, the more magical the light that can spring from their contact.' Milan Kundera in Testaments Trahis. This technique was designed after a client requested the ability to launch a click once application from another click once application.
This technique is designed to meet this requirement. The only way (to the best of my knowledge) too reliably, dynamically, launch an installed click once application, off line, is through this process, thus meeting the clients requirements. If your clients have this requirement then feel free to use this technique, but if they do not then you do not need this technique. Did this answer your question?
![Where is clickonce app installed Where is clickonce app installed](/uploads/1/2/5/4/125461658/781887447.jpg)
Shawn Weisfeld President Orlando.NET Users Group. 'Did this answer your question?' Did you ever ask your 'client' why they required this? Did you explain to your client that ClickOnce publishing gives you the option to publish in an 'online-only' mode (no Start menu entry on your local machine) or in an offline mode (Start menu entry on your local machine, checks for updates when on-line, and automatically updates the app or its data files or resources automatically with some user prompting depending on settings).
Perhaps you are describing what is necessary to 'shell' an offline-only mode ClickOnce application remotely from another process? I assume, but have not personally tried, that you could make an offline-only ClickOnce app scriptable, set to startup automatically with Windows, subject to start-up by Windows Scheduler. Perhaps the last alternative would require your technique of 'de-referencing' the shortcut? Best, Bill 'The greater the social and cultural distances between people, the more magical the light that can spring from their contact.'
Milan Kundera in Testaments Trahis. I did explain the capabilities of ClickOnce to the client, but to the best of my knowledge this is the only technique to start a ClickOnce application from another ClickOnce application. There goal was to make a completely off line application that could be started from another completely offline application.
![How to remove clickonce application How to remove clickonce application](http://keithelder.net/blog/images/keithelder_net/blog/WindowsLiveWriter/ClickOnceRunningatStartup_AACF/image_12.png)
Some might call this a ‘shell’, and this technique would be useful for scriptable situations. I am not sure you mean by ‘de-referencing’ the shortcut. Shawn Weisfeld President Orlando.NET Users Group. Ahh, I understand now, you want to use my technique of launching a click once app from another click once app and you want to be able to pass the second app some information from the first application. I don’t know of any way this is supported with click once. My guess is that you are going to have to resort to the traditional methods of inter-processes communication (i.e.
Write the information to a database table or file and have the new app read that when it launches, or send a message using WCF etc from one process to another, etc.).