| Comments

Silverlight logoAt last, Silverlight 3 is released!  It has been a long road…wait a minute, actually it’s only been 8 months since the last release!  Whoa, that’s some wicked supersonic Microsoft time there!  Anyhow, we are finally released.  A while back I wrote a post on What’s New in Silverlight 3 and it still all applies.  I’d encourage you to read that post as well.  There are, of course, some subtle changes in a few things from an implementation side of things, but those are all documented in the release.

Here’s where you go to get the exhaustive goods.  First if you don’t have Visual Studio or Silverlight yet installed and want to try it out, give the Web Platform Installer a try.  In one click we’ll install everything for you!  The image link here will install VS2008 Express (free) and the Silverlight 3 developer tools:

Here’s some links to all the other bits if you so desire:

That should give you the totality of information to get as deep as you want with all the features.

NOTE: If you are behind a firewall and get an error installing the VS tools, you may be running into a common issue with those ‘behind the walls’ with downloading the runtime.  Basically download the tools, then download the *developer* runtime (link above) and follow the offline instructions here (this was a post from earlier days but still applies).

While you are downloading the bits, take a look at some thoughts on new/changes below here.

What’s changed/new since beta?

There are a few things that are finally in the bits that we’ve talked about since beta but probably not many have seen or been able to work with.  Here’s some of my highlights:

Improved text rendering.  The team made large investments in improving the overall rendering of text in Silverlight applications.  Improved text rendering is available to all supported platforms.  Improvements for text animation have also been introduced.

Updated Out-of-browser tooling.  In the beta, the manifest had to be written by hand for taking your Silverlight application out-of-browser.  The Visual Studio tools now have a user interface for helping you do that.  When you look at the properties dialog of a Silverlight application you’ll now see the checkbox to enable these settings:

Silverlight Out of browser settings

and the resulting tooling to create the file for you:

Silverlight Out of browser settings dialog

The result is that an OutOfBrowserSettings.xml file is created and your .*proj file is decorated with some build instructions on how to compile that for the manifest.  If you have existing projects with the older settings in the manifest, it should be a quick and easy change, but I had also created a quick tool that was helping me do these in bulk.  You are welcome to use my OOBChanger ClickOnce app.  You basically point it at the folder where your Silverlight .**proj file is located and it does the work.  This is certified works on my machine utility, but I wanted to pass it along in case you had a lot to do.

NOTE: Remember to DELETE THE OLD AppManfiest settings (Deployment.Identity) or your application WILL NOT RUN.

In addition to the tooling change, almost all the Out-of-browser APIs got name changes.  For instance, instead of .Detach() it is now .Install().  Also the out-of-browser update model I’ve previously talked about has change slightly.  There is now an API called CheckAndDownloadUpdateAsync() which triggers the update check.  Once called, if an update is available, it is being downloaded asynchronously to the user.  There is an event you can subscribe to for the completion of this event to check if an update did indeed occur and alert the user.  The change here effectively is that you, the developer, now perform when you want that update check/download to occur.

Where did my design view go?!  You may notice right away that the VS tools no longer have the preview mode for your XAML in Silverlight projects.  This is by design.  We heard some pretty vocal feedback that the preview was usually turned off for most development because it was not turning out to be helpful as the applications got more complex.  The team decided put the resource investment into creating a great editable design surface in VS2010 instead and not delay the release of Silverlight 3.

ASP.NET Server Controls.  In the Silverlight 2 SDK and the Silverlight 3 beta, we had two ASP.NET server controls: asp:Silverlight and asp:Media.  These were both controls that served as wrappers to emitting the <object> tag or other JavaScript to instantiate a Silverlight object.  The <object> method is more flexible for developers on various platforms and we have decided not to include updates to these controls for Silverlight 3 SDK.  People may ask how they are going to emit params, etc. using server code, and that is still entirely possible.  We have a whitepaper talking about various methods of doing that including the simplest ones like this:

   1: <object type="application/x-silverlight-2" ...>
   2:   <param name="Source" value='<asp:Literal id="Source" runat="server"/>' />
   3: </object>

That whitepaper about the ASP.NET Server Controls can be downloaded from the Silverlight whitepapers site and includes some guidance, known issues, and things to be aware of if you are still using those controls and move to Silverlight 3.  It also includes a link to where you can get the source code for those controls if you want to extend them yourself.

Silverlight.JS updates.  Just a minor update that we compressed the bits so that if you want to use them it is a 7K library instead of a 57K library.  The “debug” (human readable) version will be available for you to download if needed at the Silverlight.js code site and is licensed under Ms-PL.

New networking stack.  What?!  That’s right a new networking stack option is being introduced for Silverlight 3 and is new since beta.  Silverlight has always leveraged the browser HTTP stack and will continue if you don’t care.  In Silverlight 3 we’ve introduced the Client HTTP stack as an option as well.  You must opt-in to use the client HTTP handling.  This gives you the ability to go more than just GET/POST (i.e., more REST-ful verbs), using response status codes/headers, etc.  You can opt-in to use the client HTTP stack on all requests, requests for a specific domain, or on a per-request basis like this:

   1: HttpWebRequest request = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(new Uri(
   2:         http://api.search.live.net/qson.aspx?query=Silverlight));

Hopefully this new client stack will give you some flexibility in some situations beyond what the browser networking stack was providing.  We continue to look for feedback on improving this area.

Assembly Caching.  This feature was in the beta, but was only limited to Microsoft specific assemblies and only a few.  In the release we’re making this option available to all developers.  This gives you the ability to host your satellite assemblies and not have them packaged as a part of the initial XAP payload.  They will then be download asynchronously when needed.  This feature is great for shared assemblies in corporations as well as component vendors.

Where did DataForm go? DataForm was moved out of the SDK and moved into the Silverlight Toolkit release mechanism.  It is still available in its full awesomeness of glory, but just in a different place under System.Windows.Controls.Data.DataForm.Toolkit namespace.  Look for it (and the source!) in the Silverlight Toolkit downloads.  There were some changes here including the removal of the DataFormFields (like DataFormTextField) in favor of using the primitives more.  So instead of:

   1: <datacontrols:DataFormTextField Text="{Binding Path=FirstName}" />

you’d use

   1: <datacontrols:DataField>
   2:     <TextBox Text="{Binding Path=FirstName}" />
   3: </datacontrols:DataField>

We felt this is a more flexible model for growth in the long run for DataForm usage.

Navigation framework updates.  The navigation framework got some updates including how you use the UriMapper concepts.  In the beta you had to have it as a resource and the resource key had to be named ‘uriMapper' or it wouldn’t work.  We’ve changed that so now you can still have your mappings as a resource, and can reference them on your Frame like this:

   1: <navigation:Frame UriMapper="{StaticResource MyFooMapper}">
   2: ...
   3: </navigation:Frame>

or you can explicitly write them on the Frame itself

   1: <navigation:Frame x:Name="MyCoolFrameNav">
   2:     <navigation:Frame.UriMapper>
   3:         <nav:UriMapper>
   4:         ...
   5:         </nav:UriMapper>
   6:     </navigation:Frame.UriMapper>
   7: </navigation:Frame>

Hopefully that makes things a little more flexible for you.  Also be sure to check out the additional 7 free navigation application template themes we’re providing for you.

.NET RIA Services.  The July 2009 update for .NET RIA Services is now available for you to download as well.  We’ll be posting some deeper tutorials on how to use RIA Services with Silveright.  When you download the bits, there is a walkthrough document that helps you get a good overview of the framework.  Best of all, the July 2009 bits come with a Go-Live license!  Sweet!  Now you can get rolling on some deployment using RIA Services!  Be sure to use the .NET RIA Services forums as the team is very active there!

Browser Zoom.  Silverlight applications now respond to browser zoom requests.  So if you’re viewing an app in IE you can go down to that little right corner and change the zoom to 200% and see the wonder of the ClearType text rendering :-).

Silverlight 2 changes and quirks mode.  In my previous post where I asked you all to make sure your SL2 apps ran fine under the beta, there was a lot of questions about what this quirks mode list of changes was going to be.  At the time we hadn’t formalized the document so I couldn’t share it and I didn’t want to share something incomplete.  The changes are now outlined in the Silverlight 3 changes documentation (section 5).  There are some changes that may directly affect you (like OpenFileDialog requiring a user-initiated action) and some that you won’t care about.  The key here to remember is that even if you have this code in your SL2 application, as long as it is compiled in SL2, it will ran fine in Silverlight 3 because of our quirks mode.  If you compile in Silverlight 3, however, you will be playing by SL3 rules, so pay attention if these affect you.

What’s the deal with Blend?  Expression Blend 3 is releasing a Release Candidate (RC) build alongside the Silverlight 3 final release.  Expression Blend is a part of the overall version 3 suite for Expression which is not yet released (which includes Expression Encoder 3 as well).  The RC build was designed to ensure you can target SL3 applications.  It also includes the feature everyone is talking about: SketchFlow.  Be sure to check out the RC build and play around with it…there are some great improvements.

Encoding media for Silverlight.  IIS Smooth Streaming has already been released and you can play around with it since Silverlight 2 applications.  Expression Encoder 3 features were recently announced (including screen capture!) one of which indicated that updated media templates will be provided.  Here’s a preview of some of my favorites:

‘Expression’ theme: simple, but super elegant.  Has built-in pop-out control, cover-flow style chapter/playlist viewing and offline mode support.  Wicked.  Makes me scared about my project with Joel.

Encoder 3 Expression theme

‘Jukebox’ for audio playback

Encoder 3 Jukebox theme

The source code for these templates are provided as well so you can extend and further template to your liking.  The IIS Smooth Streaming encoding capabilities are also built into the product so you can produce your own smooth streaming bits to put on your IIS7 server.


I’m sure I’m missing some things, but there is all goodness in the Silverlight 3 release.  You just have to experience it yourself :-).  Go ahead and Get Started now!  The marketing team has also updated their site at http://www.microsoft.com/silverlight with some updated case studies and additional information for you to help learn how Silverlight can empower your developers and help you create unique experiences on the web.

Hope this helps!

| Comments

I’m sure you’ve heard of the IIS7 Smooth Streaming information and perhaps even experienced it if you watched some of the NBC Olympics streams last year or the Presidential Inauguration this past January.  It’s a great experience for online media being able to seamlessly deliver quality media online without constant buffering when latency occurs in networks you don’t control, such as your customers’ ISP accounts.

You may have wanted to try out this experience yourself to see exactly what it does and how it works…as well as to simulate bad/good bandwidth.  Well, you can.  Here’s what you do:

  1. Ensure you have an IIS7 environment
  2. Download and install the Web Platform Installer which is an easy way to pick the package and have it (and any dependencies) installed for you
  3. Download the sample content (Big Buck Bunny – an digital cartoon rendered in various bitrates to simulate the experience).
  4. Download the UX Simulator player starter kit (this is the player shown below to simulate the experience)

Once you have all that installed and working, the sample content also installs a UX Simulator application which is a Silverlight application that uses one of the Expression Encoder player templates and also adds some nice features to simulate latent/changing network bandwidth speeds. 

NOTE: If you don’t have access to a server and want to try out this simulator yourself you can visit http://www.iis.net/media to see it live.

Here’s a screenshot of my session running.  The graph below shows what bitrate is being delivered.  Notice the marks where I indicate where I was seeking the media.  It drops down to that the user doesn’t get the dreaded buffering pause, but still continues immediately and then scales back to the highest quality media it can deliver.  The slider on the top right allow you to simulate a drop/increase in available bandwidth:

Smooth Streaming UX Simulator

Try this out if you are interested.  It’s a very high quality sample content, but you can also try out the UX Simulator on your own content if you use Expression Encoder and choose the adaptive profile to generate the Smooth Streaming files.  Watching the content via this simulator is a very cool experience to see it happen as it really does seamlessly change bitrates without impact to the user and without using a new stream.

| Comments

The Encoder team has updated their Silverlight Streaming (SLS) plugin for Expression Encoder 2.  On the surface pretty much nothing has changed, but it essentially updates the ability to use the plugin to publish Silverlight 2 templates to SLS automatically without getting the random error that you’ve probably seen if you tried.

Since the new Silverlight 2 player templates are completely parameter-driven, which is awesome, it did present a small challenge for the plugin.  When you use the new plugin with a Silverlight 2 player template, you’ll notice that the resulting application uses a bootstrapping method to launch with initialization parameters.  This models (in fact I modeled my information) the bootstrap method I outlined in a previous post.

With the new plugin, for media applications at least, you don’t have to mess with creating your Javascript files or manifest files…the plugin does all that for you now in the pre-processing before uploading to the SLS service.  Because all of this is in there now, my process of making the SL2VideoPlayer a one-click template in Expression Encoder is now complete!  I’ve chosen to stick with my “minimum” fork of the template (no markers or caption support) because that’s the scenario I use mostly, just a player.  You can get the template files here.  Just unzip into the Encoder templates directory and it will show up as an option.  When used, the SLS plugin correctly translates all the settings into initParams for you.

Here’s the download links:

| Comments

One of the great things I like about some of our platform products is that they are building in extensibility more and more.  Take Windows Live Writer as an example.  It’s no secret on this blog that I’ve got a geek affair with that tool.  I use it daily and have customized it (via plugins) and my blogging platform (Subtext) to make it even more of a best experience for me for web authoring.

Writing plugins for Writer has been a lot of fun and a great way to get the functionality I want/need into a workflow without having a different utility to work in.  Another one of these tools has been Expression Encoder 2 which I’ve been using a bit more lately.  Expression Encoder is a tool that enables the encoding of audio/video assets into VC-1 formats and H.264/AAC formats.  It’s a really simple tool to use and also comes with several Silverlight player templates that you can choose as a part of your output.  In one click you can have your HD home movie encoded and a rich playback experience developed for you as well.  I’ve wrote several times about Encoder, templates, etc. before and you can see some of them here:

With no shortage of information on how to do it, I got home last night and began cranking one out.  I’ve been using Amazon’s S3 web services for a while and have really grown to like it a lot.  One of the Live Writer extensions I spoke of earlier is a plugin for S3 for Live Writer that Aaron Lerch helped out with as well!  I though I should extend Encoder so that I’d have a one click publishing point to my S3 account instead of having to use S3Fox all the time (which is an awesome tool btw).

So after getting home from a user group I started cranking one out, figuring out the nuances and just coding something together.  A few hours later I came up with what I’m calling 1.0 beta of my plugin.

It’s not a fancy UI, but it doesn’t need to be, it serves a purpose: enable publishing of Encoder output directly to an Amazon S3 bucket in one click.  That’s it.  Encoding just media?  No problem.  Adding a template?  Not a problem either.  You simply need to enter your Amazon S3 account information and enter a bucket.  If the bucket isn’t there, it will attempt to create it.  You can also list your current buckets if you forgot them.

There are likely indeed a few problems and some fit-n-finish needed.  I am positive the error handling needs to be refined as well as it could probably benefit from some more efficient threading handling.  The cool think about the Encoder publishing plugins is that they are WPF user controls, so it gave me a chance to work with more XAML.

At any rate, even in the current form (which isn’t perfect but seems to be working for the specific need I built it for -- “works on my machine” warranty applies here) I wanted to share it out for any others to use and hopefully give feedback and contribute.  It’s available as a Ms-PL licensed project with source code and you can get it on CodePlex: Amazon S3 Encoder Publishing Plugin.  I hope you like it and can give feedback.  Please if you find issues log them in the Issue Tracker for the project so they are trackable.

| Comments

One of my favorite implementations is to leverage the initParams feature for the Silverlight plug-in.  This enables you to send parameters to your application prior to it starting up.  These parameters are in plain text and can be seen in the HTML source of your page, so obviously you wouldn’t want to include any sensitive information there like passwords, connection strings, etc., etc.  But it can be very helpful for re-using application logic while providing an configurable experience.  You can view a video demonstration of this and other methods of using initialization parameters on the Silverlight Community site here: Using Startup Parameters with Silverlight 2.

Media is one obvious example here as you could re-use a media player and simply provide the source of the media as an initParams value and then you’ll only have to deploy one player.  This works extremely well and enables you to leverage a content delivery network for the distribution of your app and just provide a different URI for the media each use.

For Silverlight Streaming (SLS) services, however, there is yet a parameter in the manifest.xml file that exposes a mapping of this initParams element to the loader for your SLS application. 

Microsoft® Silverlight™ Streaming by Windows Live™ is a companion service for Silverlight that makes it easier for developers and designers to deliver and scale rich media as part of their Silverlight applications. The service offers web designers and developers a free (please read terms and conditions upon registering) and convenient solution for hosting and streaming cross-platform, cross-browser media experiences and rich interactive applications that run on Windows™ and Mac. Combined with the ability to create content with Microsoft® Expression and other 3rd party tools, web designers and content publishers wishing to integrate Silverlight applications into their online properties can enjoy complete control of the end user experience.  You can sign up for an account that will give you 10GB of hosting space for your Silverlight applications.

Here’s some ways you can still leverage that method.

Method 1 – Bootstrap it

This method really would be considered when you are using some Silverlight application that is parameter driven and you want to simply use the XAP and provide the parameter.  Let’s use the media player scenario here because we can leverage a real application, the SL2VideoPlayer project on CodePlex.  This player is driven by parameters, namely one to set the media URI called “m.”  We’ll concentrate on that one.

Let’s say we want to use SLS to host our player application and we want to simply grab the XAP and upload the player and our media.  As I mentioned, SLS doesn’t yet provide a way to tell it in the manifest that there are startup parameters.  But here’s what you can do, provide a “bootstrap” method to instantiate the Silverlight application.

Step 1 – Create the bootstrap function

Just create a file of whatever you want, let’s call it launcher.js for this demo.  In launcher.js we need to write two functions: one that creates our Silverlight object, the other to call that function.  Let’s see what it looks like, then explain.

   1: function launcher(parentId) {
   2:     var parentElement = document.getElementById(parentId);
   3:     Silverlight.createObject(
   4:         "VideoPlayerM.xap",
   5:         parentElement,
   6:         "playerObj",
   7:         {
   8:             width:'800',
   9:             height:'600'
  10:         },
  11:         {
  12:             onError:null,
  13:             onLoad:null
  14:         },
  15:         'm=<your-media-uri>',
  16:         null);
  17: }
  19: function StartApp(parentId, appId) {
  20:         launcher(parentId);
  21: }

If you look at the first function called “launcher” this is the one that does the heavy lifting.  Because SLS will include the Silverlight.js file for us, we can use that API to create the instance of the plugin.  The Silverlight.createObject function generates the plugin tag for us and emits the platform/browser-specific code for the plugin.  Line 15 above shows us how we are passing the initParams argument to the function, which is a parameter of the createObject call in the API.  The second function “StartApp” is what we will tell SLS to use when loading the hosted application.  StartApp matches the required signature for SLS using the parentId (the element of the plugin) and the appId (the SLS application ID) we will need to use it.

Now in our manifest file for our SLS application we can have this:

   1: <SilverlightApp>
   2:   <version>2.0</version>
   3:   <loadFunction>StartApp</loadFunction>
   4:   <jsOrder>
   5:     <js>launcher.js</js>
   6:   </jsOrder>
   7: </SilverlightApp>

SLS will look at this manifest and do two things.  First it will ensure that the Javscript file “launcher.js” is included.  Second it will tell the system to run StartApp as the function to start first. 

That’s it – we package the manifest.xml file, launcher.js, VideoPlayerM.xap and our media file up as a zip and upload to a new application using the web administration of our SLS account.

I mention this as an option, because it does work.  However the nature of this is still pretty much a one-time use because the bootstrap function is a part of the application and thus your “parameters” are coded as a part of the launcher, coupled to this application instance.  This still does, however, help you if you want to use an app that requires it and the parameters won’t change…you’re just trying to re-use some Silverlight application!

Method 2 – QueryString params

The other option is a little work-around.  Whenever you have an SLS application you will have an endpoint to that application.  The format of that will be something like this:


Where the accountId is your SLS account id, and the applicationName is the name you’ve provided for the app you uploaded already.  Let’s assume our app was called HostedMediaPlayer and my accountId is 217, it would be this:


Now since our application requires startup parameters, clicking on the link (or using it) would generate our nice Silverlight application that does nothing.  So we need to send it the media source (the “m” parameter).  To do that we can pass in our initParams as QueryString parameters like this:


This translates to the initParam that we need.  So now we could also do something like this:


And we have re-used the same application, but for a different source, still using the parameter-driven nature of it.  I’ve tested this only using very minimal parameters and ones that are simply (i.e., string based with no funky characters, etc).


Initialization parameters are an awesome and easy way to create and re-use Silverlight applications that are parameter driven.  I hope these two methods for Silverlight Streaming services help you understand the initParams relationship better with the SLS hosted model.  Of course if you aren’t using SLS and you are hosting your own application, then you ultimately have complete control on how to send those parameters and as previously noted, there is a video on some options with that regard.

Hope this helps!  If you found this post helpful, please consider subscribing to my RSS feed or also subscribing via email.