Silverlight is a high end technology which gives developers the ability to generate web applications that can be processed within the browser. When you develop with Silverlight, it is important to understand the application structure for Silverlight.
A Silverlight application will be comprised of three things:
- The application classes or services which are implemented within the application assembly,
- The in-package library assemblies as well as resource files which can encapsulate
- The UI and functionality.
The third element which comprises the Silverlight application structure is the On-demand library assemblies or resource files which must be responsible for dealing with UI functionality.
Every Silverlight application will need to implement the functionality in order to begin running once the Silverlight plug-in has downloaded it. The Silverlight plug-in requires all the Silverlight applications to implement their startup functionality within a well known as specific manner, which is referred to as being the entry point.
Within the Silverlight application, entry points will be comprised of a number of three things, and these are a class, assembly, and metadata. The class will be derived from the actual Application, which may also be called the application class. The assembly will comprise the application class, and will be known as the application assembly.
The metadata will be responsible for specifying the application assembly and class which in turn comprise the entry point. Another important factor which is connected to the development of applications within Silverlight are Application Services.
The Application class offers numerous application services which are typically need via applications. The more critical service is the capability of notifying the UI to show whenever the application is activated. Other important services are lifetime management, initialization parameters, and the detection of unhandled exceptions.
The Library Assembly and Resource Files
The library assembly within Silverlight is used for the purpose of encapsulating important UI functionality. The library assemblies may be used for a number of different purposes, and this can include the organization of the application into smaller portions and sharing both UI and functionality via numerous applications.
While it is important for both the library as well as the application assemblies to encapsulate the various functions of the Silverlight app, this application may also be comprised of data which is non-executable, and good examples of this include video, images, audio, XAML, and XML.
There are also a number of differences between on-demand as opposed to in-package. The application package can be thought of as the thing which the Silverlight plug-in is responsible for downloading in order to activate the Silverlight program.
The application package may come in the form of a Zip file archive which is complete with the .xap file name. The application package will need to be as small as necessary in order to offer the quickest download speed possible.
Additionally, the files which should be available in the application are the ones which comprise the UI as well as the functionality that the application needs in order to function. Files which can be found within the application like the assembly and resource files are called the in-package.
The files which comprise the UI functionality can be downloaded as necessary for the files which are on demand. Another thing that is important to consider is the development of the a library assembly for Silverlight.
Creating a Silverlight Library Assembly
While one application assembly could be useful for certain Silverlight programs, Silverlight allows applications to be comprise many library assemblies. There are a number of reasons why you will want to consider using library assemblies within Silverlight.
Some of them include allowing developers to create factored and reusable units for UI or functionality which can be distributed via numerous applications, allowing third party developers to distribute or sell customized controls, and factor the application’s US or code through the use of on-demand or in-package files. This can enhance download speed and application start up time. Additionally, a positive effect may be gained in terms of performance.
The Silverlight library assembly is largely composed of code and UI. You also have the option of implementing the UserControl, and this can be done with the code as well as the UI. Along with the application assemblies, you have the option of utilizing MSBuild to create the library assembly which holds both the functionality as well as the UI.
You should never create the application package simply because it forms the library assembly. The library assembly may either be deployed on-demand or in-package, but the choice is largely made by the developer. After you have generated the deployment for the library assembly, you will need to reference it via the application assembly.
You will need to either configure it on-demand or in-package when it comes to deployment. If you want to make use of in-package deployment, then you will need to put in a reference for the library assembly via the use of the Reference property inside the MSBuild project.
The configuration may cause the library assembly that has been referenced to be placed within the application package whenever it is constructed. Additionally, the SilverlightLibrary and SilverlightApplication will be downloaded after the application package has been downloaded. The UI as well as functionality may be encapsulated via the library assembly, and you may program against it through the use of code which is managed.
The deployment of library assemblies on-demand can lower the cost of downloading the application. To define the on demand deployment for the library assemblies, you will need to put in the MSBuild code along with the project configurations.
When it comes to the in-package library assembly, you will want to configure the application project file through the addition of a reference within the library package. At the same time, it will be necessary for you to designate the library assembly which will be referenced via the application project, and which may not be found within the application package once the assembly for the application is built.
By doing this, you will have the ability to generate code which is capable of using types via the library assembly as well as compiling it. As with the library assemblies which are in-package, you may program against the UI for the library assembly along with the functionality via the application assembly through the markup or code which is behind. At the same time, without requiring you to do larger amounts of work, the application will add an exception when it attempts to utilize any class via the library assembly.