Click here to check my latest exciting videos on youtube
Search Mallstuffs

Flag Counter
Spirituality, Knowledge and Entertainment


Locations of visitors to this page


Latest Articles


Move to top
Simple silver light sample application
Posted By Sarin on Jun 13, 2012     RSS Feeds     Latest Hinduism news
2093 Views

In this article, I will give you an overview of how browser renders Silverlight application and the main components involved during the execution of Silverlight application.
First, let’s create sample Silverlight application.  Open the visual studio 2010 Go to File->Project and select Silverlight Application template.
Note:  You need to install Silverlight 4 toolkit in order to view Silverlight related project option

You will be asked whether you want to create a website to host your Silverlight application.
You also have the option to select the older version of Silverlight. If you want to access your database using WCF Ria services, VS 2010 helps you by creating it for you. Click on the enable WCF Ria service to use that option. Since this is just a sample application, we don’t need WCF Ria service

You will see two projects that are created.
1) “SilverlightApplication” project  
2) “SilverlightApplication.Web
Web Application:  It’s an ASP.NET web application.  You will see that Visual Studio has auto generated .html and .aspx page to host your Silverlight control. You can use any one of auto generated page


Let’s look at the files that are created in “SilverlightApplication.Web” web application.
1) If you open the html page or aspx page and scroll all the way down, you will see an <object> tag which looks similar to the following.
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
        
<param name="source" value="ClientBin/SilverlightExample.xap"/>
        
<param name="onError" value="onSilverlightError" />
        
<param name="background" value="white" />
        
<param name="minRuntimeVersion" value="4.0.50826.0" />
        
<param name="autoUpgrade" value="true" />
        
<a href="https://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
            
<img src="https://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
        
</a>
       
</object>
  
 “Data” and “type” attribute in <object> tag represents the Silverlight browser plug-in and MIME type (application/x-silverlight-2).  Browser uses those values to load and instantiate appropriate plug-in. In this case, it will look for Silverlight plug-in. if browser doesn’t find the Silverlight plug-in installed, it will show the image as shown below using the anchor tag wrapped up within <object> tag. Clicking on this image will download the Silverlight plug-in.
 
There are number of parameters and its value specified using <param> tag inside <object> tag.
a)
<param name="source" value="ClientBin/SilverlightExample.xap"/>
Source parameter specifies the file path of the asp.net application that browser will use to download the Silverlight content.  i.e.  Browser will download SilverlightApplication.xap file located in ClientBin folder of web application.
b) <param name="onError" value="onSilverlightError" />
onSilverlightError is the name of the JavaScript function that will be called when Silverlight plug-in generates a XAML parse error or run-time error  
c) <param name="minRuntimeVersion" value="4.0.50826.0" /> 
value of this parameter specify the minimum version of Silverlight needed to run this application. If browser doesn’t find this version installed on the client side, it will display the screen to ask user to install this version.
d) <param name="autoUpgrade" value="true" />  
This setting has no effect if you don’t have minRuntimeVersion specified.  If the value is set to true and Silverlight plug-in installed is of version earlier than minRuntimeVersion, then the browser will attempt to update Silverlight version automatically.
2) Silverlight.js: You may have noticed that there is a reference added to a JavaScript file Silverlight.js file in <head> tag of both SilverlightApplicationTestPage.aspx and SilverlightApplicationTestPage.html page.
    <script type="text/javascript" src="Silverlight.js"></script>
 Silverlight.js is a JavaScript helper file used when adding a Silverlight application to a webpage via JavaScript.  It has a number of methods but the most important are createObject and createObjectEx which are used for instantiating Silverlight.
3) SilverlightApplication.xap: Silverlight application is packaged into this file.  When you build your SilverlightApplication project, Visual studio regenerates this application package every time in the ClientBin folder located in “SilverlightApplication.Web” web application.   This .xap file is similar to .zip file.  Try renaming it as a .zip file and extract its content.  You will see following two files in the application package along with other Dll’s you have referenced in your Silverlight project.
a) SilverlightApplication.dll
b) AppManifest.xaml
SilverlightApplication.dll is the Silverlight application assembly. i.e. assembly created for your Silverlight code
AppManifest.xaml is the application manifest file that contains information like what DLLs are present in this package and which DLL contains entry point.   You will see something like the following in AppManifest.xaml file.
<Deployment xmlns="https://schemas.microsoft.com/client/2007/deployment" xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="SilverlightExample" EntryPointType="SilverlightExample.App" RuntimeVersion="4.0.50826.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="SilverlightExample" Source="SilverlightExample.dll" />
  </Deployment.Parts>
</Deployment>
  
You can see the  EntryPointAssembly, EntryPointType and RuntimeVersion configuration
Note how the EntryPointAssembly and the Deployment.Parts refer to the AppLifeCycle.dll that contains our MSIL code. The EntryPointType specifies the class contained within the assembly (DLL), which is the Start point of the application. In our application, this class is the AppLifeCycle.App (App.Xaml.cs or App.Xaml.vb)
The Application package can also include resource files, such as images or videos or fonts.



here


Share this to your friends. One of your friend is waiting for your share.
Share on Google+ Share on Tumblr Print Browser Favorite
Related Articles
Displaying Image in silverlight Datagrid
Visitors-Hits counter for your website
How Silverlight works internally
Silverlight New features & system requirement
What is Silverlight,its features and how it works
Simple silver light sample application
Add Auto suggestion to your website using AJAX AutoCompleteExender control
Easiest Way of logging in .Net
Working with AJAX ColorPickerExtender control
Working with canvas in silverlight

Post Comment