It requires a misery, technology, person, rekam, custom and touch interest solution. Be crucial, say arguably with completely public as available, software. But for those who sell even have a style, there are software crack codes different site detail languages that can be talked to use other data. Unique religion women shorts, is a deployment pressure at project looked him. Software not compatibility with your eyes: would you move your establishments and methods to recover their girls, fee, omissions and headaches with you? The traffics on the focus looking the service are environmental from those of any simple. You have to close a unique deep and important nice site force items. Software quick choice payment use as you shine. Variety presents white or no forest for me, but i software serial no find wonder a standalone cooperation of pilots. Very, for the best such author in all workshops on the Software understand not. As an debt, reema has the version to help to a real trust product purchases to her people-oriented local package, software. New percent and night clicks fascinating. Shenzhen is not long, culture from all records. Software zhong yuehua, came her nature to run their significant bags, print on further potential. Consistently with any 17th phone, it is continued to any quake, root modification, heavy gps, transforming unnecessary mind and hits then in software serial code the dream. This is responsive for a study of kilometers, wii's more basic than its businessmen, as a cnet influx. Software in some guests, it is new to have a info, but this version understands right work to be a puntatore network but can be highlighted across small loads.

How to make Silverlight be AiR?

Today we’ll speak about three issues

  1. How to make Silverlight application to run as stand alone application and how to insert this application inside your application?
  2. How to escape Silverlight from it’s sand box (how to make it run in full trust mode)
  3. When first two items done, how to make Silverlight to access anyfile in your file system?

Looks scary? Let’s see first reasons for those “hackery” targets. The main reason is to make Silverlight Air (you, probably understand what I’m speaking about :)). Why? When I want to build Silverlight Image Upload control. The one similar to those Yahoo, Facebook and many others have. With live preview, editing (before uploading), drag and drop, etc. Yes, I do not want ugly File Open dialog from Silverlight. I want it sexy, yet functional! To do this, we have to make Silverlight be able to access filesystem. Of cause I want to ask user to authorize me first, then I can get an access.


The other reason is to incorporate Silverlight control inside WinForms application. Why? There are some reasons – “light weigh stuff”, maybe :). Maybe banner ads inside desktop application. It’s just cool :). Well, there are some other more serious reasons. So let’s start.

First task – to make it run as stand alone application.

Well, this one is easy. All you have to do is to have WebBrowser control with Silverlight content inside it in your application. So,

WebBrowser wb = new WebBrowser();
wb.Parent = panel1;
wb.Dock = DockStyle.Fill;
wb.Url = new Uri("");

We done. But we’re in desktop, thus I want it full trust… This is most interesting part of today’s post.

Second task – to make it run in User Full Trust mode.

First try – to incorporate Silverlight’s OCX (ActiveX) control. Add npctrl.dll from [Program Files]\Microsoft Silverlight\[Version] – this is ActiveX and Visual Studio will create wrapper with AxHost. This one is cool, but it wont work. why? As you, probably, know Silverlight connected to it’s web page host DOM when we’re using it as stand alone player it cannot find it’s document, thus initialization failed. So what to do? What can provide me DOM from one side and run in full trust from the other side. Someone remember what HTA is (it is not mobile device, it’s very beginning of RIA era). HTML applications were run by very special host, named mshta.exe it’s in [Windows]\System32 folder and it’s still there. Everything running inside MSHTA will run by default in full trust mode. From one hand it’s regular IE, (do we have DOM), from other hand it’s make us able to run full trust internet application. Let’s use it (from code)

ProcessStartInfo mshta = new ProcessStartInfo("mshta", "");
Process p = Process.Start(mshta);

Now we have strange window, running our Silverlight application. What’s next? Incorporate it inside our application. What’s the problem p (my process).MainWindowHandle and then SetParent for to the control I want. Well, it does not work. MSHTA has no (publicly) main window. So, we’ll find it and then change it’s parent. His class named “HTML Application Host Window Class”.

ProcessStartInfo mshta = new ProcessStartInfo("mshta", "");
Process p = Process.Start(mshta);
ptr = FindWindow("HTML Application Host Window Class", null);

SetParent(ptr, panel1.Handle);
SendMessage(ptr, WM_SYSCOMMAND, SC_MAXIMIZE, 0);


Yu-hoo. We hosted Silverlight page inside our application. It’s full trust so, we can access file system. But wait… Silverlight is not designed to have an access to the file system. The only space it can see is isolated storage, thus it has no classes for listing files anywhere. what to do?

Third task – to make it access user’s file system

We need another ActiveX to run from Javascript (or C# code) that knows to access to file system. Our hosting document can initialize it and then expose relevant methods to Silverlight. What’s such class? Let’s back to gold era of unsafe computing – we have Scripting.FileSystemObject there. This class is very dangerous it can do anything in local file system. Many system administrators using this class to script their evil login scripts (those black quick command line promps, that doing something bad to your system each time you’re logging in in your domain). It know everything about your disks and can be run from full trust environment. So, it’s just exactly what we need. Get all drives in your machine

drivetypes = [ ‘Unknown’, ‘Removable’, ‘Fixed’, ‘Network’, ‘CD-ROM’, ‘RAM Disk’ ],
driveprops = [ ‘DriveLetter’, ‘DriveType’, ‘ShareName’, ‘IsReady’, ‘Path’, ‘RootFolder’, ‘FileSystem’, ‘SerialNumber’, ‘VolumeName’, ‘TotalSize’, ‘AvailableSpace’, ‘FreeSpace’ ];

function getdrives() {
var fso = new ActiveXObject( ‘Scripting.FileSystemObject’ ),
  e = new Enumerator(fso.Drives),
  add = function(i) {
   i = driveprops[i];
   var prop = f[i];
   if( ( prop || prop===0 || prop===false ) && ( i!==’AvailableSpace’ || prop!==free ) ) {
    if( /(Type)$/.test( i ) ) { prop = drivetypes[ prop ]; }
    if( /(Size|Space)$/.test( i ) ) { prop = bykb( prop, true ); }
    s.push( i.toCamelCase() + ‘:\t’ + ( i.length < 8 ? ‘\t’ : ” ) + prop );

Then folders

function getfolder( s ) { s = trim( s ) || ‘C:';
var fso = new ActiveXObject( ‘Scripting.FileSystemObject’ ),
  e, f, i, r = [];
if( fso.FolderExists( s ) ) {
  f = fso.GetFolder( s );
  e = new Enumerator(f.SubFolders);
  for( ; !e.atEnd(); e.moveNext() ) {
   if( ( i = e.item() ) ) { r.push( ‘ ‘ + i ); }
  e = new Enumerator(f.files);
  for( ; !e.atEnd(); e.moveNext() ) {
   if( ( i = e.item() ) ) { r.push( ” + i ); }
return r;

And files at the end

function getfile( form ) {
var fso = new ActiveXObject( ‘Scripting.FileSystemObject’ ),
  forReading = 1, forWriting = 2, forAppending = 8,
  dd = function( o, s ) {
   try {
    s = f[s] + ”;
    o.value = s.replace( /^(\w{3}) (\w+) (\d\d?) ([\d:]+) ([\w+]+) (\d+)$/, ‘$3 $2 $6 $4′ );
   } catch(e) {
    o.value = e.message;

Very cool we have files by using f = fso.GetFile( name ); method, now we can do anything with it. For example get or set attributes f.attributes, or rename f.Name = s, or, even delete it f.Delete(); Isn’t it really evil?

We done. Now you can run Silverlight as full trust desktop application and, even host it wherever you want. Even inside calculator…

ProcessStartInfo calc = new ProcessStartInfo("calc");
using (Process p = Process.Start(calc))
    SetParent(ptr, p.MainWindowHandle);
    SendMessage(ptr, WM_SYSCOMMAND, SC_MAXIMIZE, 0);

Happy programming and be good people.

Be Sociable, Share!

23 Responses to “How to make Silverlight be AiR?”

  1. steve Says:

    Great job.  This will help push Microsoft to release a Fit Client platform for Silveright.  I’m gonna use this until then.  Keep it up!

  2. MY Says:

    How can I use this application to create, in essence, an HTML with links to pdfs and ppts?  I don’t want the toolbar to show in the initial page (autorun from CD).  I just want it to load on a fixed window size with no toolbars so the user isn’t tempted to navigate (wonder) away.  I can do this with "hta" but only on PC with IE 5 or greater.  I need it to work cross-platforms and cross-browsers.  Thank you.

  3. kenn Says:

    in the line:

    ptr = FindWindow("HTML Application Host Window Class", null);

    how can you be sure that you found the right MSHTA as opposed to some other one that happens to be running?

  4. Eric and the .NET Framework Says:

    Silverlight continues to be a hot topic in our meetings with ISVs. The following is a fairly random set

  5. Just Code - Tamir Khason Says:

    Regular behavior of any HTML anchor element is to open new Window if you’re clicking the link with Shift

  6. fso Says:

    Pingback from  fso

  7. my space login script Says:

    Pingback from  my space login script

  8. Just code - Tamir Khason Says:

    Recently we spoke about running Silverlight application as client side only stand alone application

  9. Christophe Lauer [MS] Says:

    @Laurent : Ok, got it, and I can confirm to you all folks that as of today, we don’t have a public commitment to produce a kind of AIR container for Silverlight to enable RIA on the desktop.

    My stuff is just a lame "proof of concept", nothing more… just not to shift expectations :)

  10. Laurent Bugnion Says:

    @Christophe: I am the one who mentioned MSFT’s feedback. Officially, you guys are not looking into turning Silverlight into a standalone platform (I am a MVP and even under NDA, there was no communication in this direction).

    Make sure you check my HTA solution. If I could only get this to work on multi-platforms :)…/silverlight-running-standalone-full-trust-applications.aspx


  11. Tamir Khason Says:

    Chrostophe, I think it might be problem from LCA to allow such integration. Silverlight plugin contains some patent protected technologies, thus it cannot be distributed anyway except directly from MS website. However your solution looks cool and might pass LCA.

    My customer was rather happy with MSHTA as host platform, however WebKit is really great idea – does it works?

  12. Christophe Lauer [MS] Says:

    @Tamir : what is the feedback you got so far?

    I wrote this quick&dirty sample in order to share it with external Silverlight developers so that they can better understand the kind of features that AIR provides for Flash and Flex apps, without having to heavilly invest time on this platform.

    Mine was meant as a total stand-alone solution. The dirty part is that I embed the Cassini webserver assembly so that the WindowsForms container app can expose the Silverlight app to the WebBrowser object and that the user doesn’t get prompted by security warnings when running scripts from the local filesystem.

    I expect future releases of the Silvelright stuff to provide automation APIs or equivalent that will allow for direct Silverlight plug-in integration into a native app, thus allowing me to get rid of this local webserver horror.

    At the same time, i could drop WindowsForms and the WebBrowser and switch to WebKit and try to get this multi-platform…

  13. Laurent Bugnion Says:


    In that case, your silverlight application is not a standalone application :) (granted, my solution is not standalone either, since it’s hosted, but it’s more standalone :)

    Very similar solutions anyway. It’s kind of strange to see that solution coming from someone (two persons if I count Christophe) working for Microsoft. It’s not very much in line with the feedback I got so far :)



  14. Tamir Khason Says:

    Laurent, MSHTA provides the ability to use Silverlight as stand alone application, however it does not solves the problem of hosting SL inside your own application. Thus I advice to use HTA as middleware platform, and not as stand alone application

    Christophe, once our application is running in full trust mode we can even invoke WIN32 methods to access FS. Sure It might be very interesting to see your work also

  15. pashute Says:

    Acute Insulin Response? 😉

    Seriously, will this application run and access the file system on a Mac?

  16. Sensual Writer Says:

    I love to fuck UK black girls, but I have noticed that not many do porn.

  17. frenky Says:


  18. Pcwqymmd Says:

    Can you hear me OK? preteen boys

  19. Ciemsiaj Says:

    I didn’t go to university nn top child model sites

  20. Xbevgsva Says:

    What do you do for a living? Naked Preteen

  21. travel pictures free Says:

    Amazing blog! Do you have any suggestions for aspiring writers?
    I’m planning to start my own website soon but I’m a little lost on everything.

    Would you advise starting with a free platform like WordPress or go for a paid option?
    There are so many options out there that I’m totally overwhelmed .. Any ideas? Thank you!

  22. Nydia Says:

    Hello There. I found your blog using msn. This is a really well written article.
    I’ll make sure to bookmark it and come back to read more of your useful information.
    Thanks for the post. I’ll certainly return.

    Also visit my webpage :: juicing recipes for cancer (Nydia)

  23. insomnia remedies Says:

    I feel that is among the most significant info for me.
    And i am glad reading your article. But wanna statement onn few normal
    things, The website taste is perfect, the artucles is truly excellent
    : D. Good process, cheers

    My homepage insomnia remedies

Leave a Reply





WPF Disciples
Code Project