Friday, October 31, 2008

Silverlight 2 Charts : Building Charts using Silverlight 2 Toolkit

Another milestone in Silverlight journey, Release of excellent Toolkit for Silverlight on Codeplex, to know more about it, do visit at :

http://www.codeplex.com/Silverlight

There are few new controls added to the Silverlight Arena as :

    • AutoCompleteBox
    • ButtonSpinner
    • Chart
    • DockPanel
    • Expander
    • HeaderedItemControl
    • HeaderedContentControl
    • ImplicitStyleManager
    • Label
    • NumericUpDown
    • TreeView
    • ViewBox
    • WrapPanel
    I guess rest are very much easy and some are familiar to Web Developers which are relevent to some of the controls in AJAX Control Toolkit e.g AutoCompleteBox,NumericUpDown etc.
    Silverlight Toolkit which exclusively supports Silverlight 2 RTW and easily installable too, To download the bits, you need to visit :

http://www.codeplex.com/Silverlight/Release/ProjectReleases.aspx?ReleaseId=18804

I personally recommend to copy all the DLL files from the Toolkit to C:\Program Files\Microsoft Silverlight\2.0.31005.0\..

This will ease to add to project as reference,and it will be like central repository of all main dll files.This is just for convenience.

Step 1 : Install Silverlight Toolkit by adding reference to DLLs inside Toolkit.

Process is very similar the way we implement for AJAX Control Toolkit, Once you do that successfully, All the controls will be available on Toolbox.

Step 2 : Implement LINQ to SQL to get data for Graph.

Step 3 : Write a Silverlight Enabled WCF service to fetch data.

For Step 2 & 3 , kindly follow my old article step-by-step :

http://pendsevikram.blogspot.com/2008/10/silverlight-2-grid-with-silverlight.html

and

http://pendsevikram.blogspot.com/2008/10/silverlight-2-grid-linq-to-sql.html

Step 4 : Configure the Chart Control and Bind it with Data.

Here I am showing first demo of Pie Chart with List<> [Collection] and then I will show it with service.

XAML Code :

<Grid x:Name="LayoutRoot" Background="White">
        <StackPanel>
            <charting:Chart Height="250" Width="400" Title="PUG –Silverlight Forum Monthly Activity" x:Name="MyPieChart" >
                <charting:Chart.Series>
                    <charting:PieSeries ItemsSource="{Binding}"
                                        IndependentValueBinding="{Binding ProductName}"
                                        DependentValueBinding="{Binding Sales                    </charting:PieSeries>
                </charting:Chart.Series>
            </charting:Chart></StackPanel>
   </Grid>

C# Code :

public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Page_Loaded);
        }

        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            GetProductSales();
         }

        public void GetProductSales()
        {
            List<ProductSales> PieData = new List<ProductSales>();
            PieData.Add(new ProductSales() { ProductName = "Vikram Pendse", Sales = 10.5 });
            PieData.Add(new ProductSales() { ProductName = "Rashi Agarwal", Sales = 20.2 });
            PieData.Add(new ProductSales() { ProductName = "Prachi Oke", Sales = 30.2 });
            PieData.Add(new ProductSales() { ProductName = "Ekta Shetty", Sales = 40.1 });
            MyPieChart.DataContext = PieData;
            MyPieChart.LegendTitle = "User Activity on forums in %";
         }
    }

    public class ProductSales
    {
        public string ProductName { get; set; }
        public double Sales { get; set; }
    }

And output will be something like this :

SLPieUData

Next Step is to bind it with Service and this time I am using Bar charts along with Pie Chart.

XAML Code :

<Grid x:Name="LayoutRoot" Background="White">
        <StackPanel>
            <charting:Chart Height="250" Width="400" Title="ABC Ltd.- Q2 Business Development Report" x:Name="MyPieChart" >
                <charting:Chart.Series>
                   <charting:PieSeries ItemsSource="{Binding}"
                                        IndependentValueBinding="{Binding Salesperson}"
                                        DependentValueBinding="{Binding Percentage}" >
                    </charting:PieSeries>
                </charting:Chart.Series>
            </charting:Chart>
            <charting:Chart Height="250" Width="400" Title="ABC Ltd.- Q2 Business Development Report" x:Name="MyBarChart">
                <charting:Chart.Series>
                    <charting:ColumnSeries ItemsSource="{Binding}" Title="Sales"
                                        IndependentValueBinding="{Binding Salesperson}"
                                        DependentValueBinding="{Binding Percentage}" >
                    </charting:ColumnSeries>
                </charting:Chart.Series>
            </charting:Chart>
            </StackPanel>
    </Grid>

C# Code :

Service Code :

public class MySvc
    {
        [OperationContract]
        public List<MonthlySale> GetSalesData()
        {
            MyDatabaseDataContext db = new MyDatabaseDataContext();
            var temp = from sales in db.MonthlySales
                       where sales.Salesperson.Length > 0
                       select sales;
            return temp.ToList();
        }

    }

[Note : I have created a Table MonthlySales in Northwind Database for testing purpose.]

C# Code with Proxy of the Service after consumption :

public partial class Page : UserControl
   {
       public Page()
       {
           InitializeComponent();
           this.Loaded += new RoutedEventHandler(Page_Loaded);
       }

       void Page_Loaded(object sender, RoutedEventArgs e)
       {
           Proxy.MySvcClient svc = new Proxy.MySvcClient();
           svc.GetSalesDataCompleted += new EventHandler<SL_SilverlightToolkit.Proxy.GetSalesDataCompletedEventArgs>(svc_GetSalesDataCompleted);
           svc.GetSalesDataAsync();
       }

       void svc_GetSalesDataCompleted(object sender, SL_SilverlightToolkit.Proxy.GetSalesDataCompletedEventArgs e)
       {
           MyPieChart.DataContext = e.Result;
           MyPieChart.LegendTitle = "Business Generated in %";

           MyBarChart.DataContext = e.Result;
           MyBarChart.LegendTitle = "Business Generated in %";
       }

   }

And the result will look like :

SLFinalCharts

This is how we can implement Charts in Silverlight 2 using Silverlight Toolkit, Soon I will post more interesting demos in coming days with more and more controls and unique ideas, Hope this will help you to start doing development with Silverlight Toolkit.

Vikram.

Wednesday, October 29, 2008

Windows Azure : Getting Started with Cloud – Part 1

PDC event..A most happening event in world for all techies, unfortunately people like me can’t travel over to US from India due to some restrictions in day-to-day,but thanks to Internet which still gives feels that like PDC is just happening next corner.

Well, before reading this article, I recommend you to visit following site and get all your concepts clear about “Cloud”.

http://www.microsoft.com/azure/webdev.mspx

http://dev.live.com/

If you are willing to work on some of the terms which you must have heard like Cloud Computing and Services, Live Mesh,SaaS [Software As A Service] etc. then Windows Azure is good thing to start of with.

Azure Service platform basically a internet based service hosted in Microsoft Data Centers and provides OS and services with support of variety of languages and protocols to empower developers to create application on the fly and can be integrate with Windows Live Services and Microsoft Dynamics.

For more information visit :

http://www.microsoft.com/azure/whatisazure.mspx

For developing Cloud Service from Windows Azure, you need to download 2 things :

  • Windows Azure SDK
  • Windows Azure Tools for Visual Studio

http://www.microsoft.com/azure/sdk.mspx

One humble note : You have to have IIS installed on your machine else setup might not allow you to install SDK

Initial Installation Screen will look like :

az1

After successful setup of SDK and Tools,Open Visual Studio,There you will find one template under both VB and C# as “Cloud Services”

az2 

az3

Choose Web Cloud Service and now you will get following structure of Cloud services shown below with a full fledge ASP.NET application.

az6

There are two files for Service Configuration and Service Definition, I have added one H1 Tag in my aspx page for testing purpose and once I run this, it will run on local IIS or Visual Studio built-in hosting environment.

az5

az4

If you want to do some changes like protocol change from http to https etc, you can very well do that from config files, they are close to the config files which we use in WCF services.

az8

Running on http need to be run on Port 80 and https on Port 443.

az7

WebRole and what is exact use of the Instance tag that I will cover in next part of this article soon.

For Deploying this on Cloud you need to right click on Cloud Service project and need to choose “Publish” option, once you click on that, It will generate 2 files which you need to host on Cloud instance.

azpublish

Cloud instance will automatically get open in browser as follows where you need to sign in with Live ID, this is bit similar to Silverlight.live.com service, here also you need to upload the files which are generated during Publish.

azdep1

azdep2

azfinal

Since for final deployment here, one need to have token, I am yet to get that token to move ahead and enable certain services which are right now disabled for me[Refer “Hosting Services” option in above screenshot where I need to host is right now disable]. So hope this will help you to get overall view, will explore it more in depth in coming part of this article.

Vikram.

Tuesday, October 28, 2008

Silverlight 2 : Download Contents on Demand

First of all, wishes to all my Blog readers..”Happy Diwali and Wonderful upcoming New Year”

This week was full of fun and joy..well Windows 7 is getting ready to public today !! My Best wishes to Windows Team for their Hard Work throughout.

Well,coming back to Silverlight 2, we saw several demos on media and images, This post will help you to not only set Source of Media and images dynamically but also you can do this with cross domain, Its not very difficult but can turn into nightmare if not done systematically.

Aim of this article to reduce XAP in size by not to adding each and everything as content,Media server I am not sure each and everyone will go and buy, So another good option is to host them on IIS with creating virtual directory with videos and pictures. I am not sure about performance comparison between IIS and Media Server though, It just another tip and trick to make things simple to understand,develop and maintain.

Step 1 : Download Contents

For calling contents like Videos and images following code will work :

namespace SLDownLoadProgress
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Page_Loaded);
        }

        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            WebClient ws = new WebClient();
            ws.OpenReadCompleted += new OpenReadCompletedEventHandler(ws_OpenReadCompleted);
            ws.OpenReadAsync(new Uri("http://localhost:1425/Videos/numbers.wmv"));
            ws.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ws_DownloadProgressChanged);

        }

       void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            try
            {
                MyProg.Value = (double)e.ProgressPercentage;
                Mystk.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                HtmlPage.Window.Alert(ex.InnerException.ToString()); 
            }           
        }

        void ws_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                StreamResourceInfo srcinfo = new StreamResourceInfo(e.Result as Stream, null);
                MyVid.SetSource(srcinfo.Stream);
                MyVid.Play();
            }
            catch (Exception ex)
            {
                HtmlPage.Window.Alert(ex.InnerException.ToString());
            }  
        }
    }
}

Observe carefully following things :

  • I have fixed Port here as 1425, Its good thing to do when you are trying it locally, Developer need to Understand Absolute and Relative path well, “AG_E_NETWORK_ERROR” which is common error, remember that it is always due to irrelevant Path.
  • I am handling two events over here as OpenReadCompleted()[ This is for actual logic implementation] and another one is DownloadProgressChanged() [ This is for keeping track of amount of download]
  • I am using StreamResourceInfo for streaming and for Images you might need to Cast images while downloading content with help of BitMapImage instance.

As far as Cross-domain downloading is concern or let it be within same IIS instance with different virtual directories, Since Silverlight is client side technology though it will not allow you direct access to data or drive any way, so to address this issue you need a XML file named as “clientaccesspolicy.xml” ,content of this file will be like :

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

Some of my friends who blog on silverlight had mention that this file is not needed,practically I don’t belive this, so I will suggest you to have this in your both application, The application which is demanding and application which is providing the contents. This is very useful also in cases like transfers between http and https, so its good practice to have this file.

Step 2 : Show Download Progress by Silverlight 2 ProgressBar controls and other techniques like showing “Loading…” images.

XAML Code : [Here you have 2 options, either show progress by progress bar or show Loading Image.

<Grid x:Name="LayoutRoot" Background="White">
    <StackPanel x:Name="Mystk">
        <TextBlock x:Name="Mytxt" Text="Downloading..." Canvas.Left="100"/>
       <ProgressBar x:Name="MyProg" Height="25" Minimum="0" Maximum="100" />
        <!--<Image x:Name="Loader" Source="http://localhost:1425/Images/loader.jpg" Height="100"/>-->
    </StackPanel>
    <StackPanel>
        <MediaElement x:Name="MyVid"/>
    </StackPanel>
</Grid>

As I said above you can go for image also, I have commented that particular code, if you want you can put it on.

Managed C# code for this :

Again for showing the delay you can either create instance of StoryBoard and implement timer kind of functionality or you can use one thread in sleep mode with some specific delay.

Here download completed part will take care of Progress, You can see both the techniques in code below [Well, you need to decide and separate out each as per your requirement specification]

public partial class Page : UserControl
    {
        Storyboard timer = new Storyboard();

        public Page()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Page_Loaded);
        }

        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            WebClient ws = new WebClient();
            ws.OpenReadCompleted += new OpenReadCompletedEventHandler(ws_OpenReadCompleted);
            ws.OpenReadAsync(new Uri("http://localhost:1425/Videos/numbers.wmv"));
            ws.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ws_DownloadProgressChanged);

            timer.Duration = TimeSpan.FromSeconds(50);
            timer.Completed += new EventHandler(timer_Completed);
            timer.Begin();

        }

        void timer_Completed(object sender, EventArgs e)
        {
            if (MyProg.Value <= MyProg.Maximum)
            {
                MyProg.Value += 1;
                timer.Begin();
            }
        }

        void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            try
            {
                MyProg.Value = (double)e.ProgressPercentage;
                Mystk.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                HtmlPage.Window.Alert(ex.InnerException.ToString()); 
            }           
        }

        void ws_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                StreamResourceInfo srcinfo = new StreamResourceInfo(e.Result as Stream, null);
                MyVid.SetSource(srcinfo.Stream);
                MyVid.Play();
            }
            catch (Exception ex)
            {
                HtmlPage.Window.Alert(ex.InnerException.ToString());
            }  
        }
    }

If you feel this is tricky and difficult,life can be made easy by putting this silverlight control in update panel and implement Update Progress to show that its “Loading..” with some image.

For such technique you can refer my old article :

http://pendsevikram.blogspot.com/2008/03/implementing-ajax-with-updateprogress.html

I hope this will ease your job and helpful for you to manage contents of silverlight on demand especially when they are large in size.

Vikram.

Wednesday, October 22, 2008

Silverlight “Live” Streaming

My friend Mayur Tendulkar called me yesterday and we decided to utilize some of our diwali vacation time spending on some Silverlight R&D. We both are frequent speakers in Community and always we deliver some sessions monthly. We decided to deliver some of those by means of Video,so Silverlight Streaming is what we conclude to be the good option.

So, I am now doing that and this post will explain you how simple video/xap can be uploaded and stream over internet, Thanks to Microsoft and Silverlight.live.com team for making life easy !!

Step 1 : Open http://silverlight.live.com/

Welcome

It is free and you will get around 10 GB of Hosting space as they claim. You just need to sign in with your Live/Hotmail/MSN id and rest will be taken care of.Once you sign in, you will get one Account ID and a complex long Account Key. You will also then able to see 3 options on left panel as Manage Account,Manage Application and Manage Videos as shown below.

ManageStream

Step 2 : Click on Manage Applications 

Once you click on Manage Applications,it will then ask you to enter application name, here I am giving sample name for test purpose,my code ahead will be on pre-created application.

It will also show you current/already created application with their size and one option as Upload an application to upload your xap.

ManageApplication

CreateNewApplication

Step 3 : Configure Application

Once you Create an application,by default it will show you three options as Upload Updated Application – This is in case if you had made any changes in application and re-builded it. Second option is Launch Application Test Page-This will launch application on Test page,this is just to cross-check whether application is working or not,and last option is Delete Application.

The application has a well formated Manifest,you will see this option with [Edit] link, click on that to configure it ahead.You will see following screen which will take all necessary information like Silverlight version and other few parameters like Frame Rate,Windowless mode etc.

ConfigAppV2

Once you click on Update, it will give you the previous screen where you will find several options with some code in <iframe> and javascript format which you can embed in your silverlight application and start doing streaming.

IFrame

ScriptnNamespace

Method 2 will help you to invoke a full fledge Server control inside your application. Some code will look like this :

1. With <iframe> in HTML Sample Page [ This is just sample Code might be different when you develop this because of change in URL]

<body>

<iframe src=http://silverlight.services.live.com/invoke/75985/WEDV/iframe.html scrolling="no" frameborder="0" style="width:500px; height:400px"></iframe>

</body> 

2. With xmlns and <script>

<head>

<script type="text/javascript" src="https://controls.services.live.com/scripts/base/v0.3/live.js"></script>
<script type="text/javascript" src="https://controls.services.live.com/scripts/base/v0.3/controls.js"></script>

<head>

<body>

<devlive:slscontrol silverlightVersion="2.0" src="/75985/TestApp/"></devlive:slscontrol>

</body>

So, that’s the end of it, just save application and Run, Your first Silverlight “Live” Streaming application is ready !! For more information on Silverlight “Live” Streaming visit at :

http://silverlight.live.com

Hope, this will be useful for you for your media centric applications,let me know your feedback.Thanks.

Vikram.

Tuesday, October 21, 2008

Silverlight 2 Grid with Silverlight Enabled WCF Services

With ref. to my previous post on Silverlight 2 Grid : LINQ to SQL + WebServices, I would like to just add this post as a patch to it [In our terms we call it “Service Pack” :) ]

Astoria I am working on it, so may be I will drop more light on that part around this weekend [Diwali festival preparation is on head]

Microsoft given a wonderful template as “Silverlight enabled WCF Service”, well extention is still svc as it was for WCF and it is for Astoria too [Entity Framework ADO.NET services] which comes with SP of Visual Studio 2008

See the pictures below :

SolutionExplorerforSLEnableWCF

From above fig. SLSrv.svc is our Silverlight enable WCF service, See the below diagram so that you will get idea how that is there :

SLEnableWCF

What I like most about Silverlight enable-WCF services is they are much more simple than WCF and they have unique flavor of old ASMX services, so you may not find an separate Interface –class file to implement the Operation Contracts, All goes in one file which is good thing from developers point of view, especially newbies often get confuse with WCF for their initial days of development.

So, rest all part is same like adding ref., creating proxy etc. code will look like follows :

namespace SLEnableWCF.Web
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SLSrv
    {
        [OperationContract]
        public List<Cust> DBConnect()
        {
            MyDatabaseDataContext db = new MyDatabaseDataContext();
            var temp = from cust in db.Custs
                       where cust.CustName.Length > 0
                       select cust;
            return temp.ToList();
        }
        // Add more operations here and mark them with [OperationContract]
    }
}

This is how we can go ahead and add whatever no of Operation Contract here with their signature and implementation.

This makes life easy and again XAML.cs code will be as is like it was earlier, like to fire completed event and calling async() method.

I leave this part below without any explanation for my users, sort of excercise for them :

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

Well, if you feel that you want some more differences between this Silverlight enable service and other services, A good post is here :

http://silverlight.net/blogs/msnow/archive/2008/09/22/silverlight-tip-of-the-day-43-silverlight-enabled-wcf-services-versus-asmx-web-services.aspx

So, I hope now you will drop WCF weapons and pick up this new one, I will be back with tons of new things like Astoria,LINQ to XML and offcourse Silverlight !

Vikram.

Thursday, October 16, 2008

Silverlight 2 Grid : LINQ to SQL + WebService

Last 2 days went like some carnival, lots of mail exchanges and forums post..Silverlight 2 finally came out of shell after wait of last few painful months,but it was fun playing with those RC and Betas.

Silverlight Grid was till the day bit out of focus for me,rather overall Data binding part I was not touching, so I decided its good time now to start doing something good in this arena.

We don’t have DataSet ?, We are not able to get System.Data namespace, I am not good at WCF but I know asmx services, Is WCF is the only way for data binding?

So many questions from last couple of days..here is my answer in bits and pieces which I will be empowering with more post in coming days.

So lets get ready to Bind a simple DataGrid in Silverlight Project.[I assume you know all pre-requisites from Software point of view, if not explore more on http://silverlight.net/GetStarted/ ]

Open a new instance of Silverlight project, it will look like :

SoultionExplorer

Note : With Silverlight 2 now you have “Silverlight.js” file for creating better installed experiences and other customizations.

Step 1 : Add LINQ to SQL

Right click on Web Project and say Add New Item, you will get following window where you need to select LINQ to SQL template and give some name to it.[e.g MyDatabse.dbml]

LINQTOSQL

Now take on table from database,I took Cust from Northwind database.

DBML

Step 2 : Invoke WebService [ asmx one..and not WCF]

We need to add a WebService so as to pass data from LINQ to SQL to Silverlight Grid, one point to be taken note of is that,Silverlight rather data binding in Silverlight is now a days like other applications,more generic oriented and not dependent on old modals like DataSet etc, so all work will now managed by List<Type>.

WebASMX

Code will be like :

        [WebMethod]
        public List<Cust> DBConnect()
        {
            MyDatabaseDataContext db = new MyDatabaseDataContext(); //LINQ to SQL instance
            var temp = from cust in db.Custs
                            where cust.CustName.Length > 0
                            select cust;//LINQ Query
            return temp.ToList(); // Result in form of List<Type>
        }

Step 3 : Add Service Reference & Program the Silverlight Grid

Now your logic is ready which will send a List<Type> with data to your silverlight application, now put a Grid on canvas which will look like :

<data:DataGrid x:Name="MyGrid"
        GridLinesVisibility="Horizontal"
        HeadersVisibility="Column"
        RowBackground="AliceBlue"
        IsReadOnly="True"
        CanUserResizeColumns="False"
        Margin="0,5,0,0">
</data:DataGrid>

and write code to create proxy of that service in your code behind file here it is, Page.xaml.cs and code will be :

public partial class Page : UserControl
   {
       public Page()
       {
           InitializeComponent();
           this.Loaded += new RoutedEventHandler(Page_Loaded);
       }

       void Page_Loaded(object sender, RoutedEventArgs e)
       {
           MyService.DBConSoapClient svrc = new MyService.DBConSoapClient();
           svrc.DBConnectCompleted += new EventHandler<SLDBDemo.MyService.DBConnectCompletedEventArgs>(svrc_DBConnectCompleted);
           svrc.DBConnectAsync();           
       }

       void svrc_DBConnectCompleted(object sender, SLDBDemo.MyService.DBConnectCompletedEventArgs e)
       {
           MyGrid.ItemsSource = e.Result;
       }

}

I hope the code is very straightforward and self explanatory..So now save and just run it !! it will look like in Browser as :

OutPut

So..our first Silverlight 2 Program is ready !! and that too its Data Binding Demo,so now get ready for more demos soon, will back here very soon with more. Thanks !

Vikram.

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.

Wednesday, October 1, 2008

“Rosario” = Visual Studio 2010 + .NET 4.0

“Learning never stops ...”

True !! whosoever has made this statement, well..coming back to “Rosario”, Yes my new friend to whom now with I need to spend my days and night in coming year or so..

Who is he? from where and what all qualities??, you want to know more..just check link below then..

http://www.microsoft.com/presspass/press/2008/sep08/09-29VS10PR.mspx

Hope, this information will be more than sufficient to know right now..

Well, now Jokes apart..Microsoft has recently announce Next Version of Visual Studio and .NET Framework Family, you must have already come to know about this from link above.

Yes ! Visual Studio 2010 and .NET Framework 4.0

I came across one Concept IDE Visual Studio 2010 link here :

http://www.codeproject.com/KB/cs/concept_ide.aspx

Interesting..Some more information on this MSDN page too..do check this out :

http://msdn.microsoft.com/en-us/vstudio/products/cc948977.aspx

So..conclusion..”Be Ready for Next Big Revolution…”

Vikram.