Silverlight 4 RC and the “silent installation”

This is written up elsewhere but I experimented with it myself today so thought I’d share.

With Silverlight 1 and 2 I used to show a picture on a slide that said something like;

“Silverlight is for rich internet applications running in the browser”

When Silverlight 3 came along with the out-of-browser capability, I revised that a little to say something like;

Silverlight is for rich internet applications initially launched from the browser”

and now with Silverlight 4 RC and its “silent install” capability I guess I’m going to have to say;

Silverlight is for rich internet appliations”

and leave it at that 🙂

If you take an out-of-browser application in Silverlight 4 you can then take the resultant XAP and email it to your friend or put it into a zip file on a website or copy it to a USB stick or anything like that and on another system you can use the sllauncher.exe application ( which is the application used to launch out-of-browser apps ) to install the application without you ever having visited a webpage.

Note – this means having Silverlight already installed. I don’t think that you can distribute the plug-in here, the user already has to have it ( I think the licensing stops you distributing the plug-in )

I can do this for both regular out-of-browser apps and trusted out-of-browser apps.

As a quick walk-through, if I was to make an application in VS 2010;

image

and then I was to “design” a quick UI which has a TextBox, a WebBrowser control and a Button as in;

image

( i.e. a textbox, a button and a webbrowser control )

As an aside, I am now starting to finding that it’s quicker to sketch that in the VS designer than it is to type in XAML even though the speed of typing XAML in VS 2010 RC is way beyond the horrible perf I was getting in beta 2.

and then a little code behind the button ( yes, I know – it’s just a quick knock together example and I missed out bindings and ViewModels and so on here );

  public partial class MainPage : UserControl
  {
    public MainPage()
    {
      InitializeComponent();
    }

    private void OnGo(object sender, RoutedEventArgs e)
    {
      this.webBrowser1.Navigate(new Uri(this.textBox1.Text));
    }
  }

then I can mark that as being an out-of-browser app;

image

and then build it.

I can then move to the debug folder and use the sllauncher.exe to install it;

image

which was actually;

"c:\Program Files\Microsoft Silverlight\sllauncher.exe"

  /install:MyGreatWebBrowserApp.xap

  /origin:http://www.mtaulty.com/slapps/MyGreatWebBrowserApp.xap

  /shortcut:desktop+startmenu

then I can run up the app from the desktop shortcut that’s been created;

image

and navigate to my web site;

image

but I can’t navigate to ( say ) www.microsoft.com because the app thinks it came from www.mtaulty.com and so that would be a cross-domain request that it’s not prepared to make and it’s even worse as I have no error handling and don’t pick that up.

But, I could make it a trusted application if I go back to my settings and even apply special sauce like taking away its window chrome ( which opens up the question of how the user will size/move/close it but there is an answer to that on the MainWindow class 😉 );

image

and then rebuild it and reinstall it with sllauncher.exe passing an additional /overwrite flag and then I can run it again and it can now go anywhere it wants because it’s trusted.

image

Update 1 – I think I chose a bad example in picking the WebBrowser control because as far as I can tell it can go to any website whether the app is trusted or not. That is – it doesn’t seem to follow cross domain policy. Regardless – you’ll get what I was trying to say if you read the above – the point here wasn’t about this particular control, it was about the silent installation stuff.