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
How Silverlight works internally
Posted By Sarin on Mar 19, 2012     RSS Feeds     Latest Hinduism news
2987 Views

To understand this, let see a diagram from the  MSDN documentation <https://msdn.microsoft.com/en-us/library/cc221363(VS.95).aspx> that gives us the  much better picture and much better understanding of the Silverlight application.

Your Silverlight control runs in a managed environment (Silverlight Common Language Runtime), which in turn runs in the context of a browser plug-in.  And that plug-in runs in the context of a web page that is downloaded from a web server to the client machine.
  
Below are the steps explaining the detailed inner working of a Silverlight based web application
  
      1.    Upon the first request, the .html page is downloaded from the web server to the client and the browser begins rendering the HTML content

      2.    The browser reaches the <object> tag, which indicates that a plug-in should be loaded, started up, and allowed to run so as to show remaining content of the page. You specify the location of the application package that the plug-in should download
    
    3.    To figure out how to call the plug-in, the browser uses the value of the type attribute on the object tag. In our cases, this type is application/x-silverlight-4.  This is a MIME type <https://en.wikipedia.org/wiki/MIME_type>, which maps to Silverlight 4
  
  • Under Windows, there is a registry entry that associates this MIME type with an ActiveX control named AgControl.AgControl, which in turn is implemented by a DLL npctrl.dll, located in "installed directory\Program Files\Microsoft Silverlight\4.0. xxxxx.0"
  • So npctrl.dll is the actual plugin implementation-an unmanaged Windows DLL that implements the plug-in API and, in turn, launches the Silverlight CLR-the execution environment in which your Silverlight control actually runs. Npctrl.dll is both a classic Win32 DLL (non-COM), as well as an ActiveX control (COM server) and mode it runs, depends on the browser.   When running inside of Internet Explorer, the plug-in runs as an ActiveX control, implementing the IXcpControl COM interface.  However, when running in other browsers, like Mozilla, it implements the Netscape Plug-in API, running as a classic Win32 DLL.  (It implements functions like NP_Initialize and NP_GetEntryPoints.
          
      
        4.    If the correct version of Silverlight has not been installed, then the browser will ask to install else the browser loads the Silverlight plug-in and creates the Silverlight content region as explained in step 3. The plug-in then begins downloading your .xap file.  
        5.    The Plug-in extract the contents of the .xap file and read the AppManifest.xaml file from the XAP to determine the assemblies your application uses.
            
          6.    The plug-in loads the Silverlight core services (Silverlight Presentation Core) and the Silverlight runtime environment (CLR) which then creates an Application Domain for your application.
        Silverlight Presentation Core

  • Within the Silverlight plug-in, the layer to take control is the Silverlight Presentation Core.  
  • The Presentation Core is responsible for rendering everything in the browser, handling user interaction, playing video and parsing XAML.  It’s implemented in agcore.dll, which is a classic Win32 DLL.  (Not a COM server and not a .NET executable).
  • When your browser starts up (in Firefox, at least), both npctrl.dll (Plug-in) and agcore.dll (Presentation Core) are loaded.  The remaining Silverlight runtime libraries are only loaded when you actually load a page containing a Silverlight control.
            Silverlight CoreCLR/ Silverlight runtime environment
  • The CoreCLR, or Silverlight Common Language Runtime, is the Silverlight version of the CLR that runs inside the Silverlight plug-in. This is the managed environment that your Silverlight applications run inside; similar to the CLR that hosts thick-client .NET applications.
  • The CoreCLR is implemented in coreclr.dll, also in "installed directory\Program Files\Microsoft Silverlight\4.0.xxxxx.0".  The CoreCLR is based on the same codebase as the desktop version of the CLR, but much smaller, and with features not required in a browser environment removed.  (In the desktop world, the equivalent DLLs are mscoree.dll and mscorwks.dll).
  • Note: coreclr.dll is also just a “plain old” unmanaged Win32 DLL.  It is the implementation of the .NET CLR, so it does not run in a managed environment itself.
            7. When the package is downloaded, the plug-in then loads your application assemblies and dependencies (if any) into the AppDomain. The CLR uses the metadata in .xap to instantiate your Application class and the default constructor of the Application class raises its Startup event and other events as shown below. Other than providing an Application start point, it manages resources as well as provides events useful during the lifecycle of the Silverlight application.  
    C#
    public App()

    this.Startup += this.Application_Startup;
    this.Exit += this.Application_Exit;
    this.UnhandledException += this.Application_UnhandledException;
      
    InitializeComponent();

    private void Application_Startup(object sender, StartupEventArgs e)

        this.RootVisual = new Page();

    private void Application_Exit(object sender, EventArgs e)


    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)


    The Startup event handler is handled to display a user interface page and that is how you view your UI. This event occurs once the Silverlight plug-in has finished loading the .xap file. Once the UI is loaded, other events occur in response to user actions.  
    The Exit event handler can be used to process some code just before the application is released from the memory. The Unhandled Exception handler enables you to handle errors that are not anticipated in advance.


            
  • Note: Images used on this website are either a production of Bhaktivedanta Book Trust(https://www.krishna.com), Iskcon Foundation or were found in google search under "Free to use and share". If any of the images presented here violates copyright issues or infringes anyone copyright or are not under "Fair use", then please bring it to our notice. Read Disclaimer for more.

    Share this to your friends. One of your friend is waiting for your share.
    Related Articles
    Database cannot be opened due to inaccessible files or insufficient memory or disk space
    How Silverlight works internally
    Silverlight New features & system requirement
    JQuery FAQ and Jquery Effects
    What is Silverlight,its features and how it works
    Jquery features, Advantages and disadvantages
    How AJAX Works, advantages and disadvantages
    Calling silverlight methods from javascript
    Working with forms-Jquery form selector
    Working with canvas in silverlight

    Post Comment