Hi!
I am just about finished making a gadget - and I'm making the gadget detect if there is a newer version out there. So I compare the System.Gadget.Version and another version number coming via a XML, and if the xml file shows a newer version, the gadget notifies the user about the new version and gives her a link.
Now, I have been testing this and there are some shortcomings. Let's say I'm currently running a gadget called mygadget.gadget, and its in my localapp/sidebar folder (since its installed) and it has version no. 0.9. Little later there is a newer gadget with 1.0 version and the xml notifies the 0.9 gadget about the new version. The user clicks the link (that just appeared) and I get the Install dialog... (i did set up the mime type on server)... now the install dialog tells me its about to install mygadget[1].gadget (notice that [1] its adding - probably because there is already a file with the same name in there). The gadget installs fine, but now I'm running two instances of the gadget. One new, and one old. Is there any way that the sidebar can take care of this and uninstall the old one when installing the new one
I also tried to fool the [1] - thingy, by renaming the old 0.9 file as mygadget[1].gadget and see what would happen when the newer 1.0 version would be downloaded/install. In this case the operating system does not do anything about the filename, even though its the same. So now it tries to install the new file as mygadget[1].gadget, but in the end tells me it can't do it, because I'm currently using the other (old gadget) file. So how are users supposed to be updating their gadgets multiple times without running into these annoying problems.
Thanks!
Best Regards,
Thor.

Version upgrade for gadgets
MDesigner
It's not gallery that's giving your gadget the [1] suffix, but explorer. If you name your gadget with foo[1].gadget and explorer sees a conflict, you'll download it as foo[1][1].gadget instead.
ChaCh
That's not really true and Microsoft don't really need to provide a method of updating gadgets. I have a pretty good idea it can be done seamlessly without losing settings or having to restart the gadget.
brianInsTech
I do the exact same thing as the poster above.
There is still one problem - we still have all the old versions installed, even though they don't appear on the sidebar. Microsoft doesn't have any ways to 'uninstall' old gadgets from other gadgets.
Regards,
Thor.
Trish
Version check works. User downloads new gadget file, and clicks Install. Let's say my file is named myfile.gadget. After the install, I now see the following 2 files under %userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets:
myfile.gadget
myfile.gadget.~0001
Re-opening the gadget continues to open the older version (which prompts the user to upgrade again after version checking).
Any way around this
Karin P
There is however no way to automatically uninstall the old version, the user must do this manually.
Lear Cabrini
Gadget version checking code works ... OK
Added System.Gadget.close call to close old gadget .... OK
Download and install new gadget version to replace old gadget .... LOST
Can ANYTHING be done to install AND replace the old gadget version Or is the user left up to their own Windows Vista knowledge to figure out how to do a manual delete of the old gadget version
I am aware of Explorer renaming files (adding [1] and [2] and [3] and ....). Seems like there is no "auto-replace" functionality possible. Can someone confirm this
THANKS AHEAD OF TIME!!!
zoezoo
Srdjan
I actually figured it out - I thought this would be too complicated.
I just close (System.Gadget.close() ) the older gadget right after the user has clicked the link pointing to the new gadget :) Easy and simple - solves everything.
I might name my gadgets <whatevername>[1].gadget for live-gallery so that the gadget will always overwrite the old one.
Thanks!
Thor.
Gene vantreese
Gagdet:
I dont have any problems with needing to unstall, or explorer adding [1] etc. The sidebar handles the over-write process quite nicely :)
polymorphicx
If you don't want to have the user having to click on the link to open up a browser to download the new .gadget version, why don't you just use the ActiveXObject('ADODB.Stream') to download the new version and write to file.
so, for instance, if your gadget is called GadgetXXXX.gadget, you have something similar to this:
var url = 'http://yourwebsite.com/gadget/GadgetXXXX.gadget';
var path = System.Environment.getEnvironmentVariable("LOCALAPPDATA") + "\\GadgetXXXX.gadget";
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.send();
var aObj = new ActiveXObject("ADODB.Stream");
aObj.Type = 1;
aObj.Open();
aObj.Write(req.responseBody);
aObj.SaveToFile(path, 2);
aObj.Close;
a=null;
System.Shell.execute(path, null, null, open);
System.Gadget.close();
This gets rid of the problem with windows explorer renaming the Gadget file name with ...[1].gadget and also copies the file to the user's %LOCALAPPDATA% directory : C:\Users\[theuser]\AppData\Local
This is about the 'neatest' way of solving this problem till Microsoft comes round with a more elegant solution to Gadget Upgrading!
cheers!
Abisola