nwein
Posts: 577
Joined: 2011-03-28
|
I've read Alex Ben-Ari http://www.add-in-express.com/forum/read.php?FID=5&TID=4407 and have the same question: Is it possible to not show the "Launching Application" ClickOnce screen when checking for updates?
I'm calling the CheckForUpdates() function from my add-in but would like not to bother the user with that screen every time the user opens Excel, only when there's an actual update/new version.
I've looked at the code behind the CheckForUpdates and I see that it call a StartUpdates with both silent and checkOnly flags set to false. In all honesty, I think that it doesn't really matter for that specific window (image above), as either flag (silent and/or checkOnly) still calls the .appref-ms file which I think, launch that window (even though the Process calls the WindowStyle to be hidden) - as you can see I'm quite confused by how it works.
The last thing that I don't understand is how your code gets that .appref-ms file (to run it as a new process). It look like the path you're supplying is the path to the clickOnce installation (e.g. C:\Users\username\AppData\Local\Apps\2.0\XR01VXK3.PZ2\46T5W20Q.1W3\appName_01f822d53a6519b3_0001.0007_945d596e99d94a47), but there's no .appref-ms file there, only .cdf-ms |
|
Eugene Astafiev
Guest
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
I'm very aware of how to deploy and how to check for updates, you can see so from my question (I've even gone furthermore to inspect your underlying code of it...).
I also knew normal clickOnce publication can't hide that window, but was hoping that your implementation of clickOnce could do it.
Thanks for the answer though. |
|
Eugene Astafiev
Guest
|
Hi Nir,
Thank you for the clarification.
As you may probably know, there is no way to hide this window currently. However, we will consider adding such functionality to Add-in Express. Thank you for the suggestion. |
|
nwein
Posts: 577
Joined: 2011-03-28
|
Just thought I'd share with you guys that I was able to achieve this eventually by comparing my add-in's assembly version with the addin.application assemblyIdentity node, version attribute. Only if the clickOnce version is higher do I call the CheckForUpdates.
Enclosed is my code if someone is interested :)
private static bool CheckForClickOnceUpdates()
{
// Extract version number from addin.application file
string clickOnceFileName = @"path_to_addin.application";
if (!File.Exists(clickOnceFileName))
throw new FileNotFoundException("Application file not found - " + clickOnceFileName);
var xmlTextReader = (XmlTextReader) null;
var xmlDocument = new XmlDocument();
try
{
xmlTextReader = new XmlTextReader(clickOnceFileName);
xmlDocument.Load(xmlTextReader);
}
finally
{
if (xmlTextReader != null)
xmlTextReader.Close();
}
XmlElement documentElement = xmlDocument.DocumentElement;
string version = string.Empty;
if (documentElement != null)
{
for (int index = 0; index < documentElement.ChildNodes.Count; ++index)
{
XmlNode xmlNode = documentElement.ChildNodes[index];
if (xmlNode.Name.Equals("assemblyIdentity", StringComparison.InvariantCultureIgnoreCase))
{
if (xmlNode.Attributes != null)
{
XmlAttribute xmlAttribute = xmlNode.Attributes["version"];
if (xmlAttribute != null)
version = xmlAttribute.Value;
}
break;
}
}
}
if (!string.IsNullOrEmpty(version))
{
// Match clickOnce version to local assembly version
Assembly assembly = Assembly.GetExecutingAssembly();
AssemblyName assemName = assembly.GetName();
Version localVersion = assemName.Version;
Version clickOnceVersion;
if (Version.TryParse(version, out clickOnceVersion))
return clickOnceVersion > localVersion;
}
throw new VersionNotFoundException();
}
If this method returns true I know I need to call CheckForUpdates, otherwise I don't |
|
Eugene Astafiev
Guest
|
Hi Nir,
Thank you for sharing your knowledge! ;-)
We will consider adding this feature to the subsequent builds of Add-in Express. |
|