Detect ClickOnce program’s server

clickoncedeployment

I'm deploying a ClickOnce application. I need to find a way to detect from which server the application was downloaded and installed from – because the application checks for updates on launch, I know that somewhere it knows the "parent" server – can I get at that value somehow?

I need this value because the installed program needs to access services on the server that it was installed from – but that server can change depending on the deployment environment.

Best Answer

You can use

ApplicationDeployment.CurrentDeployment

(specifically, ApplicationDeployment.CurrentDeployment.UpdateLocation) to access the ClickOnce properties associated with the running instance.

Note that if you're debugging, these won't be available - you can do an

if (ApplicationDeployment.IsNetworkDeployed)

To test if you're running the application through the ClickOnce deployment.