ISSUE DESCRIPTION AND SYMPTOM:
Installation of a ClickOnce application could fail with the error message referencing a URL different from the one from the one with which the installation was executed.
Here is the error message that you could see-
An error occurred trying to download ‘http://<Server>/WindowsFormsApplication2.application’.
The setup log gets created at a location similar to the following- ‘C:\Users\<username>\AppData\Local\Temp\VSDF22.tmp\install.log’
We checked the logs for more information: Here’s a line from the log showing the failure-
URLDownloadToCacheFile failed with HRESULT ‘-2146697208’
Error: An error occurred trying to download ‘http://server/WindowsFormsApplication2.application’.
INFERENCE AND RESOLUTION:
In this scenario, we were publishing the application to an IIS web site hosted on a test server, and then the ClickOnce manifest was copied over to a production IIS server from test server. The manifests were copied under the IIS virtual directory without any modification.
For instance, while publishing the application on test server, we specified the site URL as http://test:80/publish. Later, the files are copied to a production machine and the site URL is: http://prod:80/publish.
Now when the user tries to install the ClickOnce application using the production URL, the SETUP.EXE tries to download manifests from http://test:80/publish, instead of going to http://prod:80/publish.
Actually while publishing the ClickOnce manifest, the path which is specified under the ‘Publishing folder location’ in Visual Studio, gets embedded to SETUP.EXE; so when SETUP.EXE gets executed it will try to download ClickOnce manifests from the location which is embedded in it.
There is a very simple way that is provided to change the old URL to a new one.
To change the default URL in SETUP.EXE, the following command needs to be run:
setup.exe /URL=http://< Production URL>/
Once this was modified the application was installed successfully from the production server and it worked correctly.
Content by: Keshav Deo Jain