Our users run our ClickOnce WPF application from the start menu / desktop shortcut. When the application starts each time we need to get the URL it was originally downloaded from. I tried using the ActivationUri, but this only works when it was run directly from the website setup.exe rather than the desktop / start menu shortcut:
string activationUri = "???";
try
{
if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment == null)
{
activationUri = "currentDeployment is null";
}
else if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri == null)
{
activationUri = "deployment not null but uri is";
}
else if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri != null)
{
activationUri =
System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri.AbsoluteUri;
}
}
catch (Exception ex)
{
activationUri = ex.Message;
//Error getting the URL so put question mark
}
MessageBox.Show(activationUri);
When run from the setup (from a website) I would get the URL, and every other time I would get “deployment not null but URI is”.
Try ApplicationDeployment.UpdateLocation property. Unless you have configured a different update URL in the Project Properties -> Publish -> Updates -> Update Location in Visual Studio, it should return you the original deployment URL.