It turns out that when automatically updating the application, Out-Of-Browser Silverlight marks each Uri application with a time stamp that can be found in the application folder in the C: \ Users \ Trevor \ AppData \ Local \ Microsoft metadata file \ Silverlight \ OutOfBrowser (AppFolderName). Therefore, to facilitate the removal of our application in preparation for our new one, I implemented the following:
UninstallExisting(GetInstalledAppUri()); // This is how it called //This is the two method implementation // TODO: Change to your app name. const string appName = "YourAppNameHere"; static string silverlightOutOfBrowserFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Microsoft\Silverlight\OutOfBrowser"; private static string GetInstalledAppUri() { string xapFolderPath = Path.Combine(silverlightOutOfBrowserFolder, GetXapFolder()); string[] lines = File.ReadAllLines(Path.Combine(xapFolderPath, "metadata"), Encoding.Unicode); string finalAppUriLine = lines.First(i => i.Contains("FinalAppUri=")); return "\"" + finalAppUriLine.Replace("FinalAppUri=", "") + "\""; } private static string GetXapFolder() { string AppXapFolder = ""; foreach (var dir in Directory.GetDirectories(silverlightOutOfBrowserFolder)) { if (dir.Contains(appName)) { AppXapFolder = dir; } } return AppXapFolder ; } private static string silverlightExe { get { return Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft Silverlight\sllauncher.exe"); } } private static void UninstallExisting(string xapUriToRemove) { string installArgs = "/uninstall" + " /origin:" + xapUriToRemove; ProcessStartInfo pstart = new ProcessStartInfo(silverlightExe, installArgs); Process p = new Process(); pstart.UseShellExecute = false; p.StartInfo = pstart; p.Start(); p.WaitForExit(); }
I hope this helps save someone else in the hours when I needed to find out what the metadata file is and all the features of sllauncher.exe
Tchadwick
source share