Silverlight OOB - CheckAndDownloadUpdateAsync

I’ve been looking at the Silverlight Out-Of-Browser support and the easy update feature.  In the current version, we’re given the method, CheckAndDownloadUpdateAsync().  This method does a lot for us but is rather limited.  With an asynchronous method and no parameters, what can we expect?  With a huge team in Redmond working for us and trying to meet deadlines, we get what we get.  In the spirit of sharing, here’s what I see so far.

Features:

  • Detect network connectivity (and sometimes it fails miserably…)
  • Connect to the original authorized URL that it was installed from
  • Download the new XAP file and compare the current version against the downloaded version from the manifest
  • Detect the current Silverlight version vs. the new version’s Silverlight version
  • If a failure occurs, failure exception types are provided for recovery such as “PlatformNotSupportedException”

Limitations:

  • Can’t interrupted the request.  So when it times out, we wait for it.
  • Can’t download the update and make it optional to install and replace the currently running XAP.  A flag to just detect a newer version would be better.  This would allow the UI to show the current version and available update version.
  • Returns a false for the “UpdateAvailable” property for several reasons such as the new XAP is not signed, is a newer Silverlight Version, or various other errors.  We must then look at *ALL* of the possible error class types placed in the error collection.  A bunch of try-catches are therefore necessary.  The try-catches do the job as long as we have every possible error type in a catch.  An enum for the actual error reason may be better.
  • Can’t revert to a previous stable version and have it install over a newer bad version.  It makes sense, but real development teams have recovery plans when updating production versions.

Q: What if we want to make the newer XAP file replacement optional?   Here are some thoughts.

Not everyone wants to increase the newer version number for a rollback version.  The Silverlight client can call the web server to get the new version number using other networking connectivity options.  The server call could be as complicated as a WCF service, ASMX service, Web Method call, or an HTTPRequest to get the online version information.  Getting the version from the server could be as complicated as reading the newer version’s manifest file, read the new file date and time, or newer folder date and time.  It could be as simple as getting a text file that has only the expected Silverlight version and the new XAP version.  If the major or minor version is different, then the Silverlight client can act appropriately such as displaying an update message box or button to perform the CheckAndDownloadUpdateAsync() call.  The only issues I can imagine would be security issues of calling back to a “different” server where a ClientAccessPolicy.xml file is required.  If it were HTTPS from the install, the new version check call may to an HTTP.  The different server could also include “WWW” or not include it and therefore require the ClientAccessPolicy.xml file.  The simple version text file can be automatically generated in the Silverlight application build script.  This way DEV, QA, and Production can generate and test it easily without requiring the file to be edited every time it gets deployed.  This may not allow a previous version to replace a new bad version (users install updates with the Silverlight plugin, not our code) but it does get closer so the installed version can stop working or corrupting data until they uninstall and reinstall the previous version.  A rollback with a version increase is easier so we can just call CheckAndDownloadUpdateAsync for the actual rollback.  Again, these are just some thoughts to get closer to real-world deployments.

A Silverlight OOB launcher debugger is available. More information: http://blogs.msdn.com/b/silverlight_sdk/archive/2010/04/10/sllauncher-error-messages.aspx

Q: Needs some good code examples?  A few really good Silverlight OOB blog entries can be found here: http://nerddawg.blogspot.com/search/label/Out-of-browser

This should give some food for thought until we get a more robust CheckAndDownloadUpdateAsync method.

-Vince

 

Posted by vblasberg with no comments
Filed under:

Silverlightpalooza - The DFW Silverlight and WP7 DevCamp

Teresa Burger and Chris Koenig are heading up a great event on Jun 18th and 19th called the DFW Silverlight and WP7 DevCamp.  It is two full days (Friday and Saturday) of Silverlight and Windows Phone 7 fun.  Yes - I said fun.  I'll be one of the available on-site mentors both days. It will be at our favorite hang-out, the  Microsoft headquarters in Dallas.  There will be prizes and lots of experience to be gained.  So if you want to join in the fun and learning, please register now before it is filled.  After two days of Silverlight and WP7, there’s still a Sunday left to ride the motorcycle.  So it definitely will be a great weekend.


http://silverlightpalooza.dynamitesilverlight.com/


-Vince

Posted by vblasberg with no comments

Dallas XAML UG Samples for Data Binding

The Dallas XAML User Group is holding their second meeting on April 6th 2010.  We will be spending most of the time on our laptops practicing data binding techniques for WPF and Silverlight.  The completed samples are uploaded and ready to review before the meeting.  The theme for samples is a GoldWing reseller.  Can you guess which sweet Orange motorcycle that I own and love to ride around Texas, Oklahoma, and Arkansas with my wife?

WPF Routed Events – Bubbling Several Layers Up

Recently, the WPF question of the day for me was how to bubble up a toggle button event through several layers with less code.  In WPF we can easily add layers without worrying about wiring up delegates for each level.

Most of the blogs and MSDN help pages were detailed but not obvious.  This simple example shows how a registered event in the lowest level user control can bubble up for a top level parent to handle the event.  The example bubbles up an event from the QueueButton user control (Level 4) to View2 (Level 3) , then View1 (Level 2), then the top parent Window1 (Level 1) .  There is no code behind nor any delegates to maintain at any level except the firing control and any listeners.  We should be able to add any number of views in the visual tree and still avoid any extra work.  The event is a Bubble event and not Tunnel, but that is an example for another day.  Tunneling can be thought of (informally) as a falling bubble from the top level of the visible tree to the source.  This lets each level receive the event like bubble up does, but knowing that the parent control had an option of acting on the event.

I hope this simple example helps someone keep the WPF code clean and simple.

-Vince

Window1 - Level 1 - The Top Level Listener:

XAML:

<Window x:Class="Routed.Window1"
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    Title="ToggleButton Event Bubbling Example" 
    xmlns:local="clr-namespace:Routed" 
    local:QueueButton.EnableQueue="Window_EnableQueue">
    <Grid>
        <StackPanel>
            <TextBlock Text="Window1" HorizontalAlignment="Center" />
            <TextBlock x:Name="ToggleStateTextBlock" HorizontalAlignment="Center" Margin="10" FontSize="14" />
            <local:View1 />
        </StackPanel>
    </Grid>
</
Window>

 

The Single Code-Behind Method:

private void Window_EnableQueue(object sender, RoutedEventArgs e)
{
    QueueButton queueButton = e.OriginalSource as QueueButton;
    if (null != queueButton)
        ToggleStateTextBlock.Text =
"Toggle Button IsChecked = " + queueButton.IsChecked.Value.ToString();
}

 

View1 - Level 2:  (No Code Behind in View1)

<UserControl x:Class="Routed.View1"
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    Height="200" Width="200"
    Background="Peru"
    xmlns:local="clr-namespace:Routed">
    <Grid>
        <TextBlock Text="View1" HorizontalAlignment="Center" />
        <local:View2 />
        </Grid>
</
UserControl>

 

View2 - Level 3: (No Code Behind in View2)

<UserControl x:Class="Routed.View2"
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    Height="150" Width="150"
    Background="ForestGreen"
    xmlns:local="clr-namespace:Routed">
    <Grid>
        <TextBlock Text="View2" HorizontalAlignment="Center" />
        <local:QueueButton />
    </Grid>
</
UserControl>

 

QueueButton - Level 4 - The Event Source

QueueButton XAML:

<ToggleButton x:Class="Routed.QueueButton"
    xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    Height="60" Width="100">
    <Grid
>
        <TextBlock Text
="Toggle This!!!" />
    </Grid
>
</
ToggleButton>

 

QueueButton Code Behind:

using System.Windows;
using System.Windows.Controls.Primitives;
namespace Routed
{
        public partial class QueueButton : ToggleButton
        {
            public static readonly RoutedEvent EnableQueueEvent;

            static QueueButton()
            {
                QueueButton.EnableQueueEvent = EventManager.RegisterRoutedEvent("EnableQueue"
                RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(QueueButton));
            }

            public event RoutedEventHandler EnableQueue
            {
                add { AddHandler(QueueButton.EnableQueueEvent, value); }
                remove { RemoveHandler(QueueButton.EnableQueueEvent, value); }
            }

            public QueueButton()
            {
                InitializeComponent();
            }
            protected override void OnChecked(RoutedEventArgs e)
            {
                RaiseEvent(
new RoutedEventArgs(QueueButton.EnableQueueEvent, this));
            }

            protected override void OnUnchecked(RoutedEventArgs e)
            {
               RaiseEvent(
new RoutedEventArgs(QueueButton.EnableQueueEvent, this));
            }
        }
}

 

Posted by vblasberg with no comments
Filed under: ,

DallasXAML.com – A New User Group for Silverlight, WPF, XBAP, etc.

 

The Dallas XAML User Group               

               http://DallasXAML.com

 

I’ve devoted much of last month to starting the DallasXAML User Group.  I finally got back into user group management after 2 years away from leading the Dallas C# SIG.  Now I’m having fun getting a Silverlight/WPF user group going strong for the Dallas / Ft. Worth community.  Our first meeting was March 3rd at the Improving Enterprises offices in North Dallas.  We had about 25 to 35 attendees in the first meeting and it went well.  We covered the most important topic that everyone should understand well – data binding.

 

So I chose the XAML user group so we can get together for a common group improvement in the Dallas / Ft. Worth area and learn cross-technology information that we can use now.  It is not a lecture hall.  The great thing is that we’ll provide hands-on experience with most every meeting.  The goal is to get the experience that we can use the next work day.  I unfortunately broke that rule by speaking all through the first meeting, but next month is part two with more hands-on data binding.

 

The differentiation is this group concentrates on XAML, not Silverlight or Windows Client alone.  What we learn in one area, we gain for all areas.  That includes the Silverlight for Windows Phone 7 coming later this year.  Next year it may be Windows Phone 8, 9, or whatever. 

 

I started developing WPF seriously almost a year ago.  I experienced the painful learning curve.  Anyone who reports that there isn’t a big learning curve either thinks in XAML before it was developed, is on the Silverlight or WPF development team, or has already conquered the learning and forgot the pain.  So I wanted to share the pain or make it easier for others – same thing.  I have found that the more I learn and use good disciplined techniques, the more interesting and rewarding development is again.

 

A few months ago, I was sitting in the iPhone development session at the Dallas C# SIG.  After the meeting, the audience was polled for future topics.  After a few suggestions, Silverlight got the big hands up.  That makes sense because it’s still the hot topic for many Microsoft developers.  So I surfed around and found that there aren’t enough user groups to help in this area.  I polled a few local group leaders and did the work to start the group.  This week I got a telerik controls licence and improved the site with some great controls, namely the RadHtmlPlaceholder control.  It provides a Silverlight control to show HTML in an IFrame-like area.  On DallasXAML.com, the newsletters and resource pages display in HTML because Silverlight just isn’t there yet.  I’m looking forward to a Silverlight XPS viewer with flow documents.  There are some good commercial version available, but this is a non-profit group. 

 

The DallasXAML.com site points to many other resources such as podcasts and webcasts.  I would rather give them the credit than try to out-do them.  So check out the DallasXAML user group site and attend our meetings if you can.  We meet the first Tuesday of the month.

 

-Vince

DallasXAML User Group Leader

 

Good Times on the New Contract

Just a note to the blog to say that my current contract has been going well.  I'm working on contract direct from with own company, FreshMetrics, LLC.  I get to have lunch with Rob Vetter (C# MVP) from next door.  We get to catch up on user group stuff more often now.  The work is great and the team is very serious about the art of software.  It's much more silo'd and quiet than what I'm used to, but that can be a good thing.  I've been heads down with systems analysis, user interviews, and plenty of documentation before building the final application.  It's refreshing to actually have the license to discover instead of hack and go, then wonder when unit tests come into the picture if at all.  I've been pushing myself to do things right with analysis, peer review, and now I'm almost done with unit testing.  Yes - true TDD.  It's been hard not hitting the WPF and WCF services first, but the application is much better already.

The users of this application are asking for features that are easily created in a WPF - click once application.  So I finally started the DallasXAML User Group this week and it's helped at work so far for the WPF portion and the work has helped with the Silverlight User Group site that I created and deployed.  But that's the next blog entry...

 

Posted by vblasberg with no comments
Filed under:

Catching Up

Today was my last day on the extended Intuit contract.  Now I’m off to find the next great team to work with.  If anyone has projects that can be outsourced or new contracts, I’m looking.

I worked with a really great team at Intuit since February to build some features in their web sites, improve some windows services and processes, and create a few interesting web services.  All of the work entailed features and improvements to the high volume credit card transaction system.  The last two projects were the most fun.  The most recent was a WCF-based API that will be publicly available to all Intuit merchants.  The project before that was a WCF-based credit card validation service that will be available to every TurboTax 2010 installation.  I’ve had a great time with Intuit's IMS team.

Meanwhile, back at the ranch, I’ve been working on a commercial Silverlight-RIA Service project and my own long-term WPF project.  I worked for many hours this week to get more comfortable in Expression Blend 3.0.  It’s awkward for an avid Visual Studio user like me but worth the initial hurdle.  I've been very comfortable in Microsoft tools since Visual C++ 1.0 beta.  Expression Blend has so many hidden features that it's still going to take a while to get proficient.

Tonight I’m working on the new Visual Studio 2010 Web Deployment Packaging feature to more easily create and install a web site and database.  There’s always something to do with today's technology.

Caught Up,
-Vince

 

Posted by vblasberg with no comments
Filed under:

Another Contract Ends - Hanging Out the Shingle

My current contract at Intuit is ending in a few weeks.  I'm heading into a possible slow period so it's a good time to catch the blog up a little.  If nothing else but to remind myself what I've been doing through this year since leaving Notion Solutions.

 

I've been subcontracting through CraftLogic at Inutit's IMS division since last February.  In that time, I've delivered a few minor API service offerings for internal and external distribution, a few really great features, and a whole lot of maintenance to their existing high volume credit card transaction systems and web sites.  With a new framework to streamline development and support, I'm not needed as much and neither are most other contractors that would hope to join such a great team.  So I'm off to new ventures and adventures.

 

Other than their "Team Building" activities that make the team a real blast to work with, here are a few high level take-a-ways that I've had the pleasure of.

  • A refresher of Socket Development that I used to be devoted to  (no C++ this time)
  • Leveraging MSMQ for Speed and Reliability
  • The ability to really, really, really tweak those stored procedures.  And I thought I was good before I had TSQL script reviews...
  • What is Red Faction and is it ok to lose to someone named Rambo every time???

 

Any other details would start explaining the optimized and very secure processes at Innovative Merchant Solutions.  Let's just say that they are deeply committed to their work and it's been a pleasure and education working with every one of them at IGS.

 

By the way, CraftLogic has also been a great company to work with while contracting at Intuit.  They handle everything without distracting contractors like myself from the real work.  I went corp-to-corp and really appreciate their partnership.  Also as an independent contractor, I've worked on a few other commercial applications through a consulting company named Chordial Solutions.  That kept my skills fresh with ASP.NET AJAX, Entity Framework, and SSIS.

 

In the last year I've also made great progress in the integration system software that I've imagined for about 10 years.  In my own opinion, it's very unique, innovative, and valuable as a supplemental BPM and ETL system.  It's been a great enabler to gain serious experience with WPF, Silverlight, RIA Services and so much more.

 

In these past few months, I've brought considerable value to everyone's offering, including my own FreshMetrics, LLC.

 

So if you find a need for a serious contract developer, please contact me through the FreshMetrics web site.  I look forward to my next adventure with another great team.

 

-Vince
http://FreshMetrics.com

 

Posted by vblasberg with no comments
Filed under:

Life as an Independent Consultant

It’s been almost a month since I left Notion Solutions to embark on a new adventure of driving an independent consulting company.  Chris Menegay was the greatest to work with at Notion, so I truly appreciate what I learned and gave back to them.  With the new gig it’s not all easy.  There are some ups and downs that have been a challenge.  The hardest parts have been expensive insurance policies, a formal payroll, and becoming a registered Microsoft partner for an upcoming product.  With all of that behind us, it’s just work, work, work.

I’ve been holding two contracts now to make the startup ends meet.  With one client, I’m performing back-end socket, threading, and SQL work.  With the other client, I’m performing high level ASP.NET and SQL SSIS work.  To top that, I’m also advising and assisting one client with TFS configuration, one of my biggest passions.  I’m using Subversion with the other client.  So I’m keeping the skills going across the board.  This is what it’s all about (and making a profit).  Now I’m wondering how to add more hours in the day to get the work done without hiring an employee.  In consulting, as many consultants would know from experience, you must give the client their dollar’s worth or it’s back to the W2 and the nine-to-five.  It almost sounds good, but I do like being around people more than being a cubicle mushroom that a W2 tends to make you.  So that's where I'm at in this long history of blog entries.  Enough about me.

-Vince

 

Posted by vblasberg with 1 comment(s)

Azure Details and Limitations - Blobs, Tables, and Queues

The Dallas Azure User Group will be meeting tomorrow at the Microsoft offices in Irving for our second meeting.  I'm teamed up with Mike Holdorf and Rob Vettor to discuss Azure storage, namely Blobs, Tables, and Queues.  The listing below is the document that I put together to hand out at the meeting with the "Details and Limitations".  This should help us in our application designs as we move some of our systems to the cloud.  These details are from the current SDK help file.

 

Windows Azure Details and Limitations
Blobs, Tables, and Queues

( From the Windows Azure SDK Help File )

Blobs

  • Block Id - 64 Bytes Per Block
  • PutBlob - 64 MB Total
  • Blob MetaData - 8 KB Per Blob
  • PutBlock / PutBlockList - 50 GB Each
  • Blocks - 4 MB Each

 

Container Name:

  • Valid DNS Name
  • All Lowercase
  • 3 to 63 Characters
  • Starts With Letter or Number
  • Letters, Numbers, and Dash (-)
  • Every Dash (-) Must Be Immediately Preceded and Followed by a Letter or Number

Blob Name:

  • 1,024 Characters Max
  • Any combination of characters, but reserved URL characters must be properly escaped
  • Specify a delimiter within a blob name to create a virtual hierarchy though blob storage is flat and not a hierarchical

 

Tables

Table Name:

  • Only Alphanumeric Characters
  • Case-Insensitive
  • 3 to 63 Characters
  • May Not Begin With a Numeric Character
  • Up to 255 Entity Properties (including PartitionKey, RowKey, and Timestamp)
  • 1 MB Max for Combined Size of All Data in an Entity's Properties

 

Property Name:

  • Case-Sensitive
  • 255 Characters Max
  • Only Alphanumeric Characters
  • Must Begin With a Letter

Queues

  • Messages - 8 KB Max
  • Messages pushed to end of queue and popped from front of queue (FIFO)
  • Unlimited number of messages

 

Queue Name:

  • Valid DNS name
  • All Lowercase
  • 3 to 63 Characters
  • Start With a Letter or Number
  • Letters, Numbers, and Dash (-)
  • First and Last Letters Must be Alphanumeric
  • Dash (-) character may not be the first or last letter

Posted by vblasberg with 5 comment(s)
Filed under: ,
More Posts « Previous page - Next page »