I decided to revamp my NHL Schedule Outlook Importer application. By revamp, I mean start over (since I lost the code anyway). No more messing around with excel and XML. Going to do some good ol' fashioned screen scraping. It should be ready to go by tomorrow so keep an eye on this page. Here's a teaser screenshot.

So I attended the launch party at Best Buy in Bellevue. I decided to bring my 15 year old son along and he had a blast (I did too). Got plenty of free swag to take home so I was able to spread it around my 3 other kids (I kept the hat and new Halo novel). Haven't gotten to play the game yet and might not until Friday. Here's my son with his hero of the day.

Someone asked "Why would I want a WebCam Sidebar Gadget to display my webcam in realtime"?
Good question. Answer: So you are prepared when the maiger strikes again!
It's Friday. What can I say.
Here's the first of what I hope is a few more tutorials. This is pretty much introductory and explains some of the reasons why I decided to research creating a better user experience for Vista Sidebar gadget that use .NET. I show the issue that prompted me to create the application by installing and attempting to uninstall my ScreenSaver Gadget. I then show some of the registry access code one has to write in JavaScript (if you don't use the .NET Sidebar Gadget Creator). This is followed by using the creator application to generate the included sample gadget, installing it and then uninstalling it. I also briefly show the underlying JavaScript code and show that there is no registry access needed at all.
This is my very first ever video tutorial so bear with me. Right click and Save As to view it on your computer.
I wanted some more proof that my .NET Sidebar Gadget Creator works so I started a new .NET based UserControl from scratch. Guess what, it does work. After I wrote the code for the WebCamControl in .NET, I fired up the .NET Sidebar Gadget Creator, went through the wizard to create the gadget files and it worked the 1st time in the Sidebar. It literally took me about 1 minute to get it up and running (not counting the code for the actual WebCam stuff).
Here's a screenshot:
Here's a link to download the gadget:
Please note that this has only been tested locally on my machine using a LifeCam VX-6000. Your webcam may or may not work. If it does, let me know. If it doesn't...I guess let me know that too :-)
Ok, I finally worked out most of the bugs (I hope). I'll post the link and follow up with some tutorials and Sidebar Gadget development using .NET.
Here's the file...using the new SkyDrive Beta to host the file!!!
I had quite the breakthrough today. First off, I totally rewrote major portions of the .NET Sidebar Gadget Creator. It is now a wizard (photos below) that leads you through the steps to create a Vista Sidebar that uses .NET. Here are some of the changes (then I'll explain my breakthrough):
- You can now create any .NET type. You have the "option" of embedding a UserControl as the UI but it isn't required. Have a cool class you want to use. This makes it easy.
- A .gadget file is automatically created for you. More often than not, you will need to fiddle around with the final result, but just in case, I went ahead and added this feature anyway
- Reworked the entire act of copying to temp directory and registering assemblies...this is the breakthrough
As one reader pointed out, they noticed that I was simply copying the .NET assembly to the temp folder, creating the COM Interop registry keys to point to that location and having sidebar/Trident load it up from there. Was that the ideal solution? No way. He was right. It was the wrong way to do it. The benefit was that it allowed you to uninstall your gadget from the Sidebar UI, but left the file in the temp directory and orphaned registry keys.
Here's the breakthrough. What if I told you that your .NET assemblies are not copyed over. They remain in your gadget directory. What if I also told you, you don't have to worry about registration. Yeah, so. You didn't with previous versions either right since my tool did it for you. Well, what if I told you that my tool also doesn't have to worry about registering your assemblies for COM interop? You heard right. Nothing about your assembly ever gets registered into the registry (i.e. I don't register your assembly for COM interop). However, you will still be loaded just fine and if you are a UserControl based object, you will be embedded. Additionally, you can still be safely uninstalled and all the gadget files will be deleted just fine.
If you have a clue as to how I do this...feel free to submit your best guesses. I'm going to put the finishing touches on the tool and send it out. After that, I'll have a series of tutorials and an examination of the code (as well as my solution to how I solved this problem).
Here's some pics:
Are you hosting the .NET runtime and trying to create another AppDomain? Notice that you need to call CreateDomainSetup and cast the IUnknown to IAppDomainSetup to set properties? Notice also that IAppDomainSetup isn't defined in mscoree.h? Add the following (stdafx.h or anywhere else):
#import
<mscorlib.tlb> raw_interfaces_only no_smart_pointers high_property_prefixes("_get","_put","_putref")
then you can say:
CComPtr
<mscorlib::IAppDomainSetup> pAppDomainSetup;
Ta da!
OK, ran into some problems with UAC on Vista and hopefully I have it solved. I've uploaded a new version of the application. I've gotten a couple email from people that tested the last version so I want to say thanks for testing it out. Again, let me know any issues you find with this new version.
You can find it here:: NetSBHostCreator.exe
Once I think I have a good working solution in place, I'll start posting tutorials on creating a .NET based gadget and using my application to host it in Vista Sidebar.
P.S. If you get an error during installation, uninstall the previous version first. I don't feel like debugging installation issues :-)
So you want to create a Vista Sidebar gadget and you want to use .NET to do so. While it is certainly possible, it does have a few hurtles to jump. 2 of the major hurdles include assembly registration and gadget uninstallation. Let me explain:
First off, let me explain the typical setup of a gadget. Skip this paragraph if you already know. A gadget consists of a main HTML page with corresponding image and javascript supporting files. Each gadget also can optionally use a separate HTML file for settings. Each HTML file can utilize the gadget API provided by Sidebar. All the files and the gadget information itself is described using an XML file. This file contains information such as the gadget name, author, support URL, main gadget HTML filename, etc... Now, if you want to use a .NET UserControl, you have to register it as a COM server and embed it using the IE AcitveX object embedding mechanism. Easier done than said. OK, with that out of the way, let's continue.
The ideal situation is to have a user download your gadget from http://gallery.live.com and have the gadget install for you (Sidebar uses the .gadget file extension for this purpose). However, since you're not following a traditional installation path, you don't have the ability to register your assembly for COM so that it can be embedded within the HTML file your gadget uses. The current workaround is to create a Windows Shell Scripting object and manually add the registry entries each time your gadget is loaded. I won't display the code here because frankly it's somewhat ugly and susceptible with error. To further compound the problem, you have to create the registry entries in either HKCU or HKLM depending on whether the user is an administrator or not. Well, if you manage to do that, you're good to go. Of course, next time you create another gadget, you'll have to do it all again (ok, just a cut-n-paste and GUID changes but....still a pain).
The 2nd issue that occurs when trying to create a .NET based Sidebar gadget is gadget uninstallation. This is the main issue that I've seen people just can't seem to figure out (until now that is...be patient and read on. Don't skip to the end). Once your gadget is installed and running, a user should be able to open the Add Gadget window (click the + sign on top of Sidebar), right click on your gadget and select Uninstall. Sidebar then removes any instances from the Sidebar and attempts to delete the gadget files. Here's the problem (and I can't get too specific). Even though the gadget is removed from the Sidebar, the .NET assembly is still loaded within the Sidebar process. Sidebar therefore cannot remove the files and will display an error message. The 2 options you have are to restart the Sidebar or to wait a certain amount of time (I forget, but it's awhile...like 10 or 20 minutes). Not ideal for users is it.
While some developers might just think it'll be ok to let the uninstallation failure slide, you should know that when you submit your gadget to http://gallery.live.com, it will fail since it doesn't uninstall.
So, what's a developer to do? I ran into this same problem with my ScreenSaver gadget. To that end, I now present the .NET Sidebar Gadget creator (link at bottom). This is an application that will make creating a .NET based Sidebar gadget extremely easy. Wouldn't it be nice if all you had to do was (after creating your .NET control of course) fill out a few form fields, click a button and be finished? It is now. The application itself should be fairly self-explanatory when you run it. The main sticky point is that you obviously need a .NET assembly containing a UserControl that will be the main UI of your gadget (if need be, I can post the source code for the BouncingBall gadget that is included as a sample for the application).
Run the application, browse to your assembly, fill out the required information and click the Build button. The .NET Sidebar gadget creator will then reflect on the assembly and extract control information, generate HTML, JavaScript and the gadget XML files and place everything in the destination directory you specify. Here's a screenshot:
Download the application, try it out and let me know if it works/doesn't work for you.
Here's the link: NetSBHostCreator.exe
UPDATE: There is a problem with UAC. I think I have a working solution but I need to test a little more to make sure everything works fine. I'll post an updated solution soon followed closely by source code.
I found a screensaver that plays nicely with my Vista ScreenSaver Sidebar gadget. Just in time for the 4th of July!
First, go get the ScreenSaver gadget and install it to your sidebar: http://gallery.live.com/liveItemDetail.aspx?li=e321409b-231a-4da0-905c-0580c732223e&bt=1&pl=1
Next, go grab the SkyRocket ScreenSaver and install it to your C:\Windows\System32 directory: http://www.fileplanet.com/164987/160000/fileinfo/Skyrocket-Screensaver-%5BFREEWARE%5D
Open the configuration options for the Sidebar gadget and select SkyRocket. Here's a screenshot for ya:

Ok, I just ran a test with some new code that creates an .NETbased sidebar gadget and I was able to get the dll unloaded from the sidebar process so it can uninstall successfully! This is good news for all the people that can't seem to get around this issue (and there's a few of you). I'll get going on a solution and post the results here. If you want to be emailed when its ready, just ping me and I'll add you to a list.
Want a hint as to how I solved it? Take a look at this post's tags :-)
It's a milestone. My ScreenSaver Vista Sidebar gadget has hit 20000 downloads. Some people have commented that it would be nice to double click it and have it launch the screensaver. The good news is, I have a version that does exactly that (can even lock your workstation should you choose). The bad news...I can't update the gallery with a new build. Why? I'll tell you.
The gadget uses C# and therefore utilizes COM interop. However, I can't find a way to unload the dll when a user right clicks in the "Add Gadget" window and selects "Uninstall". Triden is keeping hold of my dll even though it isn't visible anymore. If anyone has some hints to force an unload, or to capture the uninstall event so I can at least inform the user or restart sidebar, I'd love to hear it.
For now you can grab the 1.0 version at:
http://gallery.live.com/liveItemDetail.aspx?li=e321409b-231a-4da0-905c-0580c732223e&bt=1&pl=1
You read right, I am leaving the WF team. I have been a WF Programmer Writer (documentation guy) for awhile now and it's been fun. WF is an awesome technology and I whole heartedly agree with the direction Microsoft is taking it. However, I'm done being a Programmer Writer. A transition date is still being discussed, but I will soon be moving into a developer role working in the Windows Live organization. Words cannot convey how excited I am to get going on the new team. I will miss the WF team but I have to move on. I was a developer at a different company before Microsoft and I came to realize that I missed being in that type of role. I will still write, but it will be relgated back to hobby status instead of a career.
I, like many other people in the Seattle area, ran the St. Patrick's Day Dash yesterday. For those that don't know, I was a formerly heavy guy (see my I'm not half the man I used to be post). Last year I ran the race I was 30 pounds heavier than I am now and the year before that I was 35 pounds heavier than that. This year I ran the course in 25:21 which was more than 3:30 less than I ran it last year. I ended up getting 853rd out of 7409 people (only counting those that wore a timing chip). I can't say I'm not pleased since I shaved so much time off last year's result, but I know that if I would have hopped off the treadmill and hit the road just a few more times before the race I could have done much better.
Anyway, for those that ran it, the results are up (and the web interface is much nicer this year I must say).
Link to Online Race Results | Race Details
Again, I have to thank Microsoft for providing the 20/20 Lifestyle program to help obese people (like I used to be) lose weight and transition into a healthier lifestyle. One of those perks that is worth more than money can buy. I lost 65 pounds but the cool thing is, I finished the program last May and to this day, I haven't put on a single pound. I've lost more body fat (I'm at 18% right now, down from about 37%) and gained more muscle. Now time to start training for my first triathlon this summer (and maybe a few more 5k and 10k's as well).