The installation/update location should be a folder, rather than the test.html file as igofed mentioned.
This next bit is not answering your question, but hopefully will prove useful to you. There is a bug in the .NET framework in the method ad.CheckForDetailedUpdate()
you are calling in your sample, in that if it is called a sufficiently large number of times (in the case of an autonomous application left running indefinitely) it will start to throw exceptions of type COMException
and InvalidOperationException
Now unfortunately I can't recall where I found out about this bug, so I'm unable to give the credit where it's due, but we solved the issue by checking the version number in manifest file and comparing it to the current assembly version.
private bool CheckForUpdateAvailable()
{
Uri updateLocation = ApplicationDeployment.CurrentDeployment.UpdateLocation;
//Used to use the Clickonce API but we've uncovered a pretty serious bug which results in a COMException and the loss of ability
//to check for updates. So until this is fixed, we're resorting to a very lo-fi way of checking for an update.
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
string manifestFile = webClient.DownloadString(updateLocation);
//We have some garbage info from the file header, presumably because the file is a .application and not .xml
//Just start from the start of the first tag
int startOfXml = manifestFile.IndexOfAny(new[] { '<' });
manifestFile = manifestFile.Substring(startOfXml);
Version version;
XmlDocument doc = new XmlDocument();
//build the xml from the manifest
doc.LoadXml(manifestFile);
XmlNodeList nodesList = doc.GetElementsByTagName("assemblyIdentity");
if (nodesList == null || nodesList.Count <= 0)
{
throw new XmlException("Could not read the xml manifest file, which is required to check if an update is available.");
}
XmlNode theNode = nodesList[0];
version = new Version(theNode.Attributes["version"].Value);
if (version > ApplicationDeployment.CurrentDeployment.CurrentVersion)
{
// update application
return true;
}
return false;
}
Your update check calling code...
if (ApplicationDeployment.IsNetworkDeployed)
{
bool updateIsAvailable;
try
{
updateIsAvailable = CheckForUpdateAvailable();
}
catch
{
//not network deployed etc...
}
if (updateIsAvailable)
{
ad = ApplicationDeployment.CurrentDeployment;
if (ad == null)
{
return;
}
ad.Update();
Application.Restart();
}
}