| Comments

MSDN Radio imageThis morning I was on a weekly (new) radio show from MSDN, hosted by Mike Benkovich.  The show, MSDN Radio, features live call-in questions that you can ask.  It was a better format than the typical live meeting text-based QA I thought.  I think hearing questions gives you a better chance of articulating your inquiry more.  Thanks to all those who listened and asked questions.  I know it seemed short and there were a few more questions in the queue – feel free to send me questions you may have.

UPDATE: The audio from the show was just posted here.

There were a few that I wanted to follow-up on and get some more answers from other team members.  Here are 3 items I wanted to provide a bit more follow-up to (I’m paraphrasing the questions).

Vince asked a question around Prism and part of that was what are the plans for Prism moving forward?  I didn’t know a concrete answer, so I quickly asked around.  Take a look at the team’s post on Prism, A Look Ahead.  The team talks about the next release (v4) to be around the September 2010 timeframe.  They also comment on using Prism today with Silverlight 4.  As to what will be in Prism 4?  They offer some insight:

  • Managed Extensibility Framework (MEF)“In particular, we’ll be looking at leveraging MEF for Component Composition (for hooking up Views and ViewModels, and other types of components), for Modularity (for the discovery, download, and instantiation of functionality packaged in a module), and for UI Composition (for mapping Views to Regions).”
  • Model-View-ViewModel (MVVM) Pattern – “…we’re looking to expand our current guidance and to include more re-usable code assets to support various MVVM scenarios. In particular, we’re looking to support common patterns for View/ViewModel interaction, hierarchical ViewModel composition, and ViewModel-based navigation. In addition, we’re also looking to provide more support for application-level structural patterns, layout management, the use of Ribbon/Popup/Dialog controls, and user state management.”
  • Data Access and Application Services (i.e., WCF RIA Services) – “…we are looking to provide guidance on using these technologies in the context of MVVM, and on patterns for data validation and caching. This area also includes the use of other services for user preferences, authentication and authorization. This latter aspect brings in the possibility of providing guidance for role-driven (or claims-driven) applications and user experience.”

I’d encourage you to subscribe to their blog and be a part of their conversation over there as well.

Scott asked a question about how to best define DomainServices (contexts) in your application – is it better to have 1:1 for entity:DomainService or other methods.  I asked the RIA Services team for some additional input to my answer. 

DomainService should be based on a set of related tasks that you expect the end-user to perform in [your application]. Typically such tasks involve a small group of closely related entities; e.g. in an Expense reporting app, Expense Report, Line Items and Details would be a good set of entities to cover in a single DomainService while covering accounts and payments in a separate DomainService type.

Additionally Jane asked about many-to-many relationships with regard to RIA Services.

Currently RIA Services require the “class in the middle” containing FK values in a many-to-many. In  a POCO model, you can add it yourself while in an EF-generated model, you would have to change the model (edmx) to add such a class in the middle.

Hopefully these provide some additional clarity on top of my opinions.  There sure seems to be a lot of interest in the RIA Services space!

Hope this helps!


This work is licensed under a Creative Commons Attribution By license.

| Comments

One of the features we are introducing in Silverlight 4 is a ‘silent install’ mechanism for out-of-browser applications.  Currently every out-of-browser application (trusted or not) starts from an in-browser mechanism.  In some instances where you want to deploy the app via managed desktop software or perhaps via CD-ROM, you don’t want to have to tell the user to start on an HTML page first.

Now I’m not going to write here about the merits of why you might want to do this other than to point out what I believe to be the 2 prominent scenarios: managed desktop deployment and CD/DVD distribution.  I know some of you might be thinking Well if it is a managed desktop environment, why not just use WPF then? – and I would pose the same question to the customer as well first.  But again, this post is to merely outline the capabilities and I’ll let you all debate the reasons :-)

The function still requires the Silverlight plugin to be installed (and requires Silverlight 4).  It would also require the ability to install out-of-browser applications (there is a possibility for an administrator to disable this feature).  Given those two requirements, the key tool at your disposal is sllauncher.exe.  This is installed with the plugin and is located at %ProgramFiles%\Microsoft Silverlight on the machine.

NOTE: The features I’m describing here are for Windows machines.  Out-of-browser applications on OSX are actually deployed as ‘apps’ (.app) versus how just the XAP is deployed on a Windows machine.  I’m investigating how to do something similar here with scripting on OSX, but I’m unfortunately not a Mac developer :-).

Let’s take a look at the required steps and a scenario.

The Setup

You’ll need to ensure that the plugin is installed as I mentioned earlier.  You’ll also want to have a copy of the XAP handy that you’ll want to be installing.  This would be the main XAP and would be the same one that would be in the Source parameter of the <object> tag where you normally would host this.

NOTE: Because “Program Files” is different on 32- and 64-bit machines you’ll want to make sure your script/installer can handle the determination of where the sllauncher.exe program will be.  Since it isn’t a native 64-bit app, it will be in “Program Files (x86)” on a 64-bit machine.  This sometimes can cause confusion because the %ProgramFiles% environment variable on 64-bit is the native program files directory and *not* the x86 one.

Your Silverlight XAP will already have to have been configured for out-of-browser and have the appropriate manifest information within it.

Once you have those you can move on to understanding the parameters.

The Options for Install

The sllauncher.exe program for install require at a minimum 2 options and I’ll suggest that you always use all 4 I will describe here.

/install:”path-toXAP-File” – this is the first and points to the XAP file you are wanting to install.  This might be on a network share, on the CD, or in an installer.  This is required.

/origin:”URI-to-origin” – this is the ‘origin’ of the XAP and is required.  Even though you might not be using auto-update features, etc. you must set this.  I actually recommend being smart about it and having the XAP on a real URI endpoint as well so that your origin is actually real.

/shortcut:desktop+startmenu – while this is optional, it actually seems silly not to include at least one – or your users will have a hard time launching your application!  You can use: desktop, startmenu, or desktop+startmenu (my recommendation).

/overwrite – this option confirms the XAP you are installing will overwrite any existing version currently there.  This is optional, but again, I think you should use it.

Let’s assume the following scenario using the Silverlight Client for Facebook application as an example.  I have the XAP (Silverface.xap) that I want to deploy.  I would use the following command:

   1: "%ProgramFiles%\Microsoft Silverlight\sllauncher.exe" 
   2:     /install:"Silverface.xap" 
   3:     /origin:"http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap" 
   4:     /shortcut:desktop+startmenu /overwrite

This assumes that I’m calling this command from where the Silverface.xap is currently.  Notice that the origin parameter points to the XAP origin and not the site hosting it.  This is important.  This above command would install the app and create shortcuts.

Automatically Launching the App

So what if you wanted to also automatically launch the app after installing (i.e., the CD/DVD ‘autorun’ scenario).  You again would use sllauncher.exe to do this for you after you’ve installed the app.  Using our same sample above here would be the command:

   1: "%ProgramFiles%\Microsoft Silverlight\sllauncher.exe" 
   2:     /emulate:"Silverface.xap" 
   3:     /origin:"http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap" 
   4:     /overwrite

Notice the emulate command.  This is the launcher.  Now you’ll notice that this isn’t the same command-line options if you looked at an installed applications’ created shortcuts.  Because the folder where the XAP gets installed is pretty random, we use the origin as the hint to the sllauncher.exe program to find the right app for us and start it up.  I’ve found that using /overwrite will also give a more consistent behavior.

Uninstalling the App

What if now you want to uninstall the app?  Perhaps the managed desktop admins deprecate an application or you want the CD/DVD experience to be a non-transient one and clean up when done.  The command again is simple:

   1: "%ProgramFiles%\Microsoft Silverlight\sllauncher.exe" 
   2:     /uninstall 
   3:     /origin:http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap

Instead of the install parameter you use the uninstall parameter.  Again, notice the use of the origin parameter – this is critical in all these tasks.  The above command would remove the application and essentially does the same thing as the right-click Remove this application context menu option in Silverlight.

Using these commands in Installers

While I think those that actually have a need for this option will be using scripts and batch files, I do think some may want to include this in an installer experience.  The only option I can see for this is because you are also deploying some additional items along with your XAP (perhaps assets to the user’s document store that the app will use later like plugins or something).  Other than that if you are creating an installer simply to wrap the above methods, it might not seem wise.

Why, you ask?  Well if you think about it, your installer itself will stamp an entry into Windows as an installed application and Silverlight will also stamp an entry.  In our Facebook example, the Add/Remove Programs would show 2 “Silverlight for Facebook” entries (assuming we named our installer that as well).  This would likely confuse the user.  I’m not saying it isn’t impossible to do this nor is it difficult to manage, I just think it looks odd.

Regardless, if you are using something like InstallShield (FYI look for InstallShield LE in Visual Studio 2010…it’s very good) or the Visual Studio Setup projects, you can include a Custom Action to these installers.  The process would be a custom action *after* the install is complete because you need to locate the XAP to install.  Most setup programs are easy to use and provide pre-configured platform-specific environment variables you can use to map to things like the correct Program Files directory.

In the ideal situation you’re batch file/installer should check for the presence of Silverlight (and the correct version).  These can be done using file path verification or registry checking, both of which are outlined in the deployment guide whitepaper.

What about redistribution of Silverlight?  Right now we do not have broad redistribution rights for Silverlight.  You will still need to point users to where they can get the plugin so that they can be presented with the EULA and get the correct version for their platform.

If you do use the installer route, make sure that you account for clean un-installations as well!

Other insights and summary

You may be asking yourself if the user will be prompted here to install the application?  The answer is no.  Since this is essentially a command-line execution, the trust is implied here.  The user first has to knowingly type the command (not likely) or knowingly execute your install mechanism (batch file, installer, whatever).  These commands cannot be automatically run from the browser, for example.  For managed desktops, sure, these may be silently installed.  This is intended because in a managed desktop environment the software is, well, managed.  An elevated or normal-privileged application will install just the same using these methods.

As to the shortcuts (the /shortcut parameter being optional).  I think we’re going to fix that in some update.  Again, it’s a bit foolish to not provide one so consider it required :-).

If you find yourself in a situation needing this, hopefully it will come in useful.  I really think this is a helpful tool, but also a niche tool.  Those of you creating general consumer applications/sites will not benefit here really because you’ll likely start with an in-browser instance anyway.  But for those using managed desktop environments, or thinking about CD ‘autorun’ type situations, hopefully this information will come in useful.


This work is licensed under a Creative Commons Attribution By license.

| Comments

Well, MIX10 is over.  It was a great time to meet a lot of people and see friends from afar.  As anyone knows, the networking is a HUGE part of being in-person at any conference…that vibe, value and friendship cannot be matched online.

But the sessions – there were a TON of them.  It is quite impossible to be in 3 places at one time.  Thankfully the MIX team record all regular sessions and make them available for viewing online or offline.  For you Silverlight developers here are my picks to ensure you watch:

And there are many more…

Since OData was a big part of MIX10 this year, I thought I’d make this easier for you to get all the MIX10 Silverlight-specific videos (my pics above and all tagged with Silverlight). 

Yes, this is yet another way to get access to the MIX videos.

The site’s RSS feed will get you *all* of MIX sessions, but you may not want that.  Unfortunately they don’t expose tag-specific RSS feeds.  Fortunately though, they DO have an OData feed available for us.  I thought I’d have some fun and play around with that.

MIX10 Online Silverlight Viewer

If I were the visitmix.com team – I’m sure they love to hear that.  But look at the list above.  If you watched each one of these, you’d be clicking a lot and going from page to page.  Why not treat them like a video library?  Let me see the ‘guide’ in one place and choose which ‘channel’ I want to watch, allowing me to switch channels quickly.  This was my vision:

MIX10 Session Viewer

Since their OData feed was exposed I could create queries to get to the list of sessions, details and video URIs.  I could (and would like) to do a lot more as far as adding a filter by tags, creating a playlist and then just hitting play, etc.  But you know, I was just tinkering.

I will have to say that the OData querying got me frazzled in some places.  OData is SUPER easy for single entity stuff, but trying to understand building up a relational query got me messed up at times since ‘normal’ LINQ querying wasn’t always supported in a translation to a URI query.  Special thanks to Jonathan Carter (@lostintangent) and Chris Woodruff (@cwoodruff) for being my ears of frustration and helping me get the right queries (didn’t end up implementing them all).

The sample MIX Viewer can be seen here and supports multi-monitor full-screen pinning (requires Silverlight 4).  So you can start a video on your 2nd monitor and go to full-screen on that one while still working on the other.

Tag-specific podcast feeds for MIX10 videos

While the MIX team does have RSS feeds for the videos, they are all-inclusive.  I would really like to have tag-specific feeds…let me search on a tag, then generate a podcast feed based on the result. 

Well, I did just that.  Since they expose the feed, I could use Yahoo Pipes to do some quick manipulation in a ‘no-code’ sort of way (yes I could have used OData, etc. blah blah – look, this was no-code/tools…just a few clicks).

So I created a podcast feed for anyone who wants to use it.  Here’s the Silverlight feed links you can use to paste into your iTunes or Zune or whatever podcast software:

If you look at the URI:

   1: http://pipes.yahoo.com/pipes/pipe.run?MediaType=WMV&Tag=Silverlight&_id=2cf69ebc6e9c4f0a1ea4bc76cfd273df&_render=rss

You’ll notice that you can just substitute the format (WMV, WMVHigh, or MP4) and the tag.  This will give you your own custom feed for your topic.

Anyhow, I really enjoyed MIX and have been catching up on all the sessions I missed.  Hope this helps you get caught up as well!


This work is licensed under a Creative Commons Attribution By license.

| Comments

If you installed the Silverlight Client for Facebook, and also upgraded to the release candidate for Silverlight 4, you may have noticed it stopped working :-).

NOTE: Applications compiled on Silverlight 4 beta will not work on machines with Silverlight RC runtime.  This is known/expected.  As with all pre-release software, this type of breaking can be expected.

We’ve recently updated the Facebook application, and you will have to re-install.  Follow these steps:

  1. Uninstall the Silverlight Facebook client.  You can do this in a few ways.  First on Windows through the Add/Remove Programs or by right-clicking on the application while it is running (even though it doesn’t work) and choose ‘Remove Application’ – I recommend the Add/Remove Program control panel option.  On Mac OSX, simply move the application to the trash.
  2. Ensure you have Silverlight 4 RC installed.  If you don’t the Facebook client welcome page will provide the links.  Reminder that this is still pre-release software and future uninstalls might be required.
  3. Visit http://bit.ly/facebookclient and follow the instructions.

You should now have the updated Silverlight for Facebook application installed.  The team received a lot of good feedback they look at.  This build doesn’t necessarily have any of those suggestions/fixes…and is more of a compatible build for the Silverlight RC runtime.  There are a few things that we finally brought forward from the initial PDC09 demonstration.

Custom Window options are clearly visible.  You’ll notice the ‘window chrome’ (as it is referred to) is gone and the custom window is in the application:

Silverlight Client for Facebook

Notice the custom maximize, minimize and close buttons:

Custom window chrome toolbar

Also notice in the lower right corner the resize adorner:

Resize adorner

The updated application also implements the ‘mini-mode’ (from the toolbar area in the upper right) which produces a stripped down view of the main news feed:

Facebook Client mini-mode

Again this is a subtle update to keep the client working for you.  These features use the custom window options available to Silverlight 4 developers.  You can read about this updated feature here and also watch a developer video tutorial on how to implement similar functions in your application here.

Have fun on Facebook and hope this helps!

| Comments

One of the announcements that happened during the MIX10 conference was the availability of the V2 of the Microsoft Translator API.  This is the engine that powers the translation behind http://www.bing.com/translate and some other Bing-related properties as well.  A lot of research has gone into the engine from Microsoft Research and others.  Language translation isn’t an easy task especially taking into consideration cultural significance of words, etc.  I have heard that the most challenging in machine translation is to Asian languages.  I will admit to not speaking any of them, so I don’t know how well we are performing here – you’ll have to let that team know if they are doing well.

After reading the announcement and working on my translate plugin for the new Seesmic Desktop Platform, I noticed that there was a Speak API.  After reading I saw this literally translates text to a WAV file for platback.  Pretty cool I thought.  I wanted to play around with this in Silverlight so created a simple application to do so:

Microsoft Translator in Silverlight

The Speak translation isn’t available for all the Translator languages (currently 30 languages for text language translation) but does support seven (7) languages: English, German, Spanish, French, Italian, Portuguese, and Russian.  So how is Silverlight talking back to you?

The Translator API comes in 3 flavors: SOAP, HTTP and Ajax.  Now I could have used the SOAP version and used Add Service Reference but I felt for what I was doing this was overkill.  The SOAP API doesn’t return me back super-strongly typed objects, so I saw little value in doing that over the REST-based HTTP methods which I decided to use.  The code is relatively simple.  I first want to translate the text input into the selected language, then pass the translated text to the Speak API and play the results in a MediaElement.

First, we use the Translate method and a WebClient call to accomplish this:

   1: private void TranslateTextToAudio(object sender, RoutedEventArgs e)
   2: {
   3:     if (Languages.SelectedIndex < 0)
   4:     {
   5:         MessageBox.Show("Please select a language first...");
   6:         return;
   7:     }
   8:     WebClient client = new WebClient();
   9:     client.OpenReadCompleted += ((s, args) =>
  10:         {
  11:             if (args.Error == null)
  12:             {
  13:                 DataContractSerializer des = new DataContractSerializer(typeof(string));
  14:                 string responseText = des.ReadObject(args.Result) as string;
  15:                 SpeakIt(responseText);
  16:             }
  17:         });
  18:     client.OpenReadAsync(new Uri(string.Format(TRANSLATE_URI, _appId, HttpUtility.UrlEncode(TextToTranslate.Text), Languages.SelectedValue.ToString(), _currentLang)));
  19: }

Notice the DataContractSerializer use here.  The HTTP API returns serialized objects, so you’ll want to use this method here to deserialize to make it easier.

After we have the translated text, we pass that to the Speak API (notice the call to SpeakIt above) which returns a Stream that is an audio/wav format.   We know that Silverlight’s MediaElement cannot directly play lossless WAV format.  But luckily there is a MediaStreamSource API that enables us to essentially write our own decoders for audio/video.  One of the Silverlight team members, Gilles, created a WAV MediaStreamSource for us to use.  After having that and not worrying about decoding, I could create a new WaveMediaStreamSource with my result Stream and set that as the Source for the MediaElement – here is the resulting SpeakIt() method (TranslatedPlayback is the name of my MediaElement in the application):

   1: private void SpeakIt(string responseText)
   2: {
   3:     WebClient client = new WebClient();
   4:     client.OpenReadCompleted += ((s, args) =>
   5:     {
   6:         if (args.Error == null)
   7:         {
   8:             WaveMediaStreamSource mss = new WaveMediaStreamSource(args.Result);
   9:             TranslatedPlayback.SetSource(mss);
  10:         }
  11:     });
  12:     client.OpenReadAsync(new Uri(string.Format(SPEAK_URI, _appId, responseText, Languages.SelectedValue)));
  13: }

That’s it!  It’s pretty cool (bonus points to you in identifying the obvious pre-filled text being used in my sample).

I’ve almost completed my Seesmic plugin and using the Translator API has made it easier.  I’ve found that a simple wrapper to the HTTP-based methods is going to make things easier for people to use, so I’ve created a Translator Client for Silverlight that I’ll be releasing once I can complete the plugin (waiting on a few things).  This will make it easier for Silverlight developers to quickly consume the API for text and Speech translation.

The code (C#) for the above sample is here: MSTranslatorSilverlightSample.zip.  You will need a Translator Application ID key to run it yourself (put it in the App.xaml resources).  If you just want to see it running really quick, you can view it here: Speak Translator for Silverlight.  You will need Silverlight 4 RC to run the sample.

NOTE: The Translator API actually doesn’t need Silverlight 4, but I just created the app using that base.

Hope this helps!