Thursday, October 9, 2008

Silverlight : “Truth” more than “Myth”…

Why I should go for Silverlight? Is it secure?

Can I migrate my old application to Silverlight? will be costly affair for us?

How it works exactly?? Similar to ASP.NET Page life cycle??..

Being a Consultant by Profession and one of the Core member of User Group..above is the common set of questions people like me always come across..especially when some new product is there.

From Day 1, we all know Silverlight is Client Oriented Technology,means it has more to do with Client [May be in terms of functionality and resource consumptions as well].

2-3 Days back I went on hunt to know exactly what’s inside Silverlight and how all things goes hand in hand. I am very much greatful to Tim Heuer and Jesse Liberty (Silverlight “Geek”) and one guy on Silverlight forum who replied me back promptly to my questions.

So without wasting much of the time,let see the following diagram which I draw in office other day just to understand myself how it works [This is totally unofficial Diagram and drawn for my understanding,maybe right or maybe wrong all together,I am just sharing that.]

SLAD

So I assume that you know what is “XAP” if not, then visit following link to know more..

http://pietschsoft.com/post/2008/03/Silverlight-Anatomy-of-an-XAP-file.aspx

I drawn above diagram on based of Some Questions and Answers which I am sharing with you now,[Read them very very carefully]

Q.1>When Silverlight Runtime is get checked and we have Install Exp. screen? is it after loading XAP or when user send request for Silverlight Application?

Answers : The default install experience would be shown if the plugin is NOT FOUND on the user's machine.

the <object> tag is the silverlight runtime control, if you do not have the control then the browser renders the install image in a normal html anchor.

Q.2>Who download XAP on client side? is it some downloader object or WebClient?

Answers : The browser is making a GET request for a resource just like any other resource for the initial XAP

the silverlight runtime control (once installed) downloaded the XAP (its a zip file) and extracts the code and resources as required. the splashscreensource parameter can set a .xaml file to download first and act as a loading screen/animation.

Q.3>While Silverlight application is running, is there a thread getting maintained with server,means if server stops responding by whatso ever reason then will Silverlight is suppose to run still since its client side?

Answers: Not by default, once the XAP is delivered, there is no connection maintained to the server unless your code is opening network sockets or something like that. It is a disconnected client application platform.

the code is all client side except for any additional/option server side web services files etc you may have added in which case it is the same as an AJAX javascript based web page.

Q.4>Once XAP got downloaded then where usually it get stored? in Temp. Internet files?

Answer : Typically it will be wherever the particular browser stores resource caching.

its a normal web browser file download the same as if your web browser downloaded an image, so yes its in the normal cache. (FF about:cache)

>>Here I jump in between : I got this in form of Screenshots : [For my localhost apps, hope same is for Live apps ;-) ]

MythSL.JPG1

MythSL2

Q.5>Since Silverlight is hosted in asp.net application mostly, so does rendering happen from actual CLR on server,if so how since XAP is zip format? or it is all together manage by CoreCLR?

Answer : Nothing is happening on the server. XAP/Silverlight are client-only applications. Everything is rendered on the client.

to keep the intiall Silverlight install small the CLR is very limited, if you look at most .xap file there various common .dll controls e.g. System.Windows.Controls.Extended.dll but it is still all client side.

I hope now you must have got the overall Idea that Silverlight working is not Myth but its Truth !! and this is how it works behind its jazzyness.

Idea of this post is to understand what exactly happens in Silverlight Program Life cycle.

Well some questions like Caching of those DLLs, disposing them,Consumption of Client Memory and are they secure if I use some Reflector tools? etc ..need to be explore more..

I hope this post will help to those who are in Learning phase of Silverlight like me..Your feedback is most welcome, indirectly it will be helpful for all instead of just Blaming Silverlight is Flash replica,not secure,waste of resources etc.

Conclusion, Silverlight going to be revolution in Web Programming sooner or later.

Vikram.

4 comments:

Vikram said...

This is really a great article. Those who are working in Silverlight should read this one.Caz it gives u rough idea what all happen "Under the Hood".

Vikram Pendse said...

Thanks for your comment.

DotNETDailyNews said...

Nice article! Although I have not yet got into sl, hope to do some day.
-N http://www.nirandas.com

Vikram Pendse said...

Thanks Nirdas !

I hope my article will inspire you to do some hands on SL,its very exciting and challenging Technology.