Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Using core runtime assemblies and other assemblies

From: Silverlight 3 Essential Training

Video: Using core runtime assemblies and other assemblies

Silverlight applications are client-side programs. In order for them to work, the code must be available on the customer's computer. The mechanism for deploying code in .NET is called an Assembly, which is nothing more than an especially configured executable file. In Silverlight, that will be a DLL file. This DLL file must be downloaded to the customer's computer before your application can start. Your code also uses other .NET classes. So, when you compile your App, you'll take dependencies on other .NET assemblies.

Using core runtime assemblies and other assemblies

Silverlight applications are client-side programs. In order for them to work, the code must be available on the customer's computer. The mechanism for deploying code in .NET is called an Assembly, which is nothing more than an especially configured executable file. In Silverlight, that will be a DLL file. This DLL file must be downloaded to the customer's computer before your application can start. Your code also uses other .NET classes. So, when you compile your App, you'll take dependencies on other .NET assemblies.

This means that these additional assemblies must also be available on the customer's computer. Silverlight has a number of assemblies that are compiled specifically for use by Silverlight applications. They contain all the types that are necessary to run your App plus hundreds of additional classes. In this regard, they are similar to the .NET and WPF assemblies. The Silverlight framework has been relentlessly reworked to be small and lean. This is to enable a fast install on the client's machine. It has also undergone a complete security refactoring to ensure that it is safe to run in a browser.

There are two sets of assemblies available. The first set is the Core Assemblies. These are essential libraries and are pre-installed on the client's computer. So, the way of saying this is when the user install Silverlight, the Core Assemblies are automatically copied to their machine. I've highlighted the Core assemblies on the right side of this slide in orange. There are five of them. The nice thing about this is your application does not need to download these files to the user's computer.

The second set are called the SDK Assemblies. These are additional Silverlight-specific libraries. They are useful but not critical. They are specifically compiled, so they work with Silverlight, but they are not automatically added to the user's computer. If you want to use something that's in the SDK assemblies, you have to do some additional work. First, you must add them to your project in Visual Studio or Expression Blend, and second of all, those must be downloaded to the user's computer. So, the deficit of this approach is your download is now bigger because you've decided to choose a Silverlight SDK Assembly.

Let's see how this works. I have switched back to Visual Studio. If you're following along with the Exercise Files, you're going to want to open the CoreRuntimeAndOtherAssemblies solution file. This is a simple project. A core message for this movie is to show you what files are generated. So, I just have it very simple application with one page. I am going to build my application, and then I am going to go look at my References folder. If you open the References folder, you'll note that I just have the Core assemblies in here, mscorlib, System.NET and so on. When I compile the application, it will create that DLL in my XAP file.

Let's go and take a look at those. I am going to go up here and choose Show All Files, and then I am going to scroll down to the Bin folder and double -click and drill down, double-click on Debug and we're going to find this XAP file. You might recall that the XAP file is just a ZIP file with another extension on it. In order to look at the contents of this I just need to go and change the extension to zip, satisfy Visual Studio that I know what I am doing by clicking on Yes, and then double-click on this ZIP file.

Now what I want you to see here is there is only my DLL and a single AppManifest file. None of the Core DLL files are in here because they are already on the user's computer and Silverlight assumes that. I am going to add a reference to an SDK assembly. I think before I do that though I should delete the ZIP file, because it's going to generate another XAP file and this will make things easier for me later. Then I am going to go up to my References folder, and I'm going to tell Visual Studio to use a SDK Assembly.

Right-click, choose Add Reference, scroll down, and find System.Windows.Controls. This assembly contains interesting controls like the TreeView control. Click OK and what do you see that's different? I now have a new node in the Reference folder called System.Windows.Control. If I compile my application and go down to my Debug folder and open up this XAP file, again, I'll have to change the extension, choose Yes, double-click on the ZIP and here is what I want you to see. System.Windows.Controls.dll is inside my XAP file.

When I deploy my application and the user runs it for the first time, it's going to take this file, download it to the user's computer, and it's now going to have a copy of System.Windows.Controls.dll for it to use locally. It's also possible for you to use your own assemblies. So, I'll show you an example of how to do that. I am going to go up here and collapse my main Silverlight Project, and then I am going to add a brand new project to the Solution. I am going to right-click on the Solution and choose Add>New Project.

What I want to do is build a library that I will use in multiple Silverlight applications. So, the key thing that I need to do here is tell Silverlight this is a special version of a .NET assembly that works with Silverlight Apps, because they are different, they have different security contexts than say .NET WinForms or .NET WPF Applications. So, I use the Silverlight Class Library, not the normal .NET Class Library. So, I'll choose Silverlight Class Library, and I'll call it something like LyndaLib for lynda Library and then I'll create a Class in here, add a new class.

I have this VideoGenerator Class, and now I am ready to compile. I have two projects. So, if I tell Visual Studio to compile, it's going to compile both of these. What I want to have happen is I want this DLL that's generated for LyndaLib - let's go look at that, here is the Bin folder, here is the LyndaLib.dll - what I want to do is move that into my Silverlight XAP file.

It's really easy to do in Visual Studio. I go to the Silverlight application and I add a reference here, just like before, Add a Reference. Remember I am in the Silverlight App now, not the lynda Library, and I click on the Projects tab. These are all the known the .NET libraries that work with Silverlight. It doesn't know about my library however, so I will go to Projects and choose LyndaLib. By doing this, Visual Studio will help me by every time I do a compile, it will first make a copy of LyndaLib in this folder, and then I will take it and copy it over to this Bin folder.

Let's see how that works, Build Solution. Now it says two successful builds. I also can see I have a reference now to LyndaLib in my References folder and if I drill down into the Bin folder, I'll have to delete this ZIP file, so I don't get a name conflict later. I am going to rename the XAP file. You should be getting used to this by now. Press OK or Yes, and then double-click on the ZIP file, and what's the key thing to takeaway here? LyndaLib is in my XAP file.

So, now this will get downloaded to the user's computer and it's available. Can you see any problems with this? I can see one. Every single time you run this application it has to copy these files to the local computer. If these are big files, it's going to take a while. That's going to mean that your application is going to be slower starting. Now what I can do is I can cache these. Silverlight has special cache. It's not the web cache. It's a special Silverlight cache. What I can do is tell it to stash these in the cache. I will stash these files in the cache. And then the first time I run the application, it will put them in the Silverlight cache.

The second time I run the application, it will use the local copy and I won't have to download these anymore. This is another simple fix. I'll show you how to do it. We'll go up to Properties. Again, this is my Silverlight App, double-click on the Properties node, come over here to the Silverlight tab, and choose Reduce XAP size by using application library caching. Done. Save the project. We'll choose build. Let's see what's different. There is the ZIP file for System.Windows.Controls and here is my CoreRuntimeAndOther. I don't need that, and I'll delete this one again.

Now, there is two ZIP files and they'll both get downloaded and the contents of this file will go in the local cache. By now, you should have a better idea of what files are created and stored in the XAP file whenever you do a compile.

Show transcript

This video is part of

Image for Silverlight 3 Essential Training
Silverlight 3 Essential Training

86 video lessons · 7771 viewers

Walt Ritscher
Author

 
Expand all | Collapse all
  1. 8m 1s
    1. Welcome
      1m 8s
    2. Using the exercise files
      1m 57s
    3. Exploring the finished project
      3m 30s
    4. What you should know before taking this course
      1m 26s
  2. 33m 28s
    1. Silverlight 3 explained
      4m 3s
    2. Showcasing amazing Silverlight applications
      2m 45s
    3. Setting up your developer computer
      3m 21s
    4. Contrasting the Silverlight versions
      1m 42s
    5. Using Visual Studio to create a Silverlight project
      6m 26s
    6. Using Expression Blend to create a Silverlight project
      2m 56s
    7. Touring the Visual Studio interface
      7m 37s
    8. Touring the Expression Blend interface
      4m 38s
  3. 39m 45s
    1. Understanding the Visual Studio project structure
      4m 11s
    2. Creating a Silverlight page/UserControl
      5m 2s
    3. Discovering what happens during a compile
      4m 53s
    4. Using core runtime assemblies and other assemblies
      9m 3s
    5. Deploying your Silverlight application
      2m 45s
    6. Starting up your application
      3m 24s
    7. Embedding Silverlight content on web pages
      4m 53s
    8. Understanding the end user install process
      5m 34s
  4. 22m 31s
    1. Exploring the relationship between XAML and .NET
      4m 43s
    2. Choosing a Silverlight programming language
      4m 56s
    3. Exploring the code-behind file
      6m 14s
    4. Debugging Silverlight applications
      6m 38s
  5. 40m 53s
    1. Working with XAML Elements and Property Attributes
      5m 52s
    2. Investigating XAML namespaces
      5m 10s
    3. Converting XAML properties with TypeConverters
      5m 43s
    4. Nesting more complex structure with Property Elements
      4m 2s
    5. Assigning runtime data via XAML Markup Extensions
      3m 37s
    6. Digging into the Dependency Property System
      7m 32s
    7. Creating a custom Dependency Property
      4m 51s
    8. Understanding Attached Properties
      4m 6s
  6. 54m 14s
    1. Understanding layout
      3m 10s
    2. Painting background and borders
      7m 10s
    3. Getting colorful with gradient brushes
      3m 37s
    4. Controlling your layout with StackPanel
      1m 52s
    5. Exploring additional layout controls in the Silverlight toolkit
      6m 4s
    6. Exploring sophisticated layout with the Grid
      9m 41s
    7. Sizing cells using the GridSplitter
      2m 54s
    8. Absolute positioning with the Canvas panel
      4m 38s
    9. Scrolling content with the ScrollViewer
      3m 15s
    10. Adjusting content with alignment, margins, and sizing
      4m 7s
    11. Enlarging your window with Full Screen mode
      2m 21s
    12. Manipulating elements with transforms
      5m 25s
  7. 23m 16s
    1. Understanding routed events
      4m 13s
    2. Wiring up event handlers in Silverlight
      6m 36s
    3. Understanding Event Bubbling
      5m 21s
    4. Detailing the mouse events
      3m 43s
    5. Detailing the key events
      3m 23s
  8. 48m 45s
    1. Displaying text on the screen
      3m 37s
    2. Gathering text input from the user
      4m 13s
    3. Using and embedding Silverlight fonts
      3m 11s
    4. Understanding content controls
      3m 27s
    5. Understanding the button controls
      6m 16s
    6. Showing list data with ItemsControls
      4m 36s
    7. Exploring the Silverlight toolkit controls
      6m 47s
    8. Digging into the DataGrid
      5m 40s
    9. Using DataBinding to work with data
      6m 46s
    10. Floating UI with Popup and ToolTip
      4m 12s
  9. 19m 7s
    1. Swapping content with UserControls
      6m 7s
    2. Creating dialogs and child windows
      5m 57s
    3. Using the Navigation Framework
      7m 3s
  10. 19m 43s
    1. Adding binary resource files to a Silverlight project
      4m 37s
    2. Showing static images with the Image Control
      4m 8s
    3. Painting UI with the Image Brush
      3m 45s
    4. Embedding video with the MediaElement
      7m 13s
  11. 21m 45s
    1. Understanding Silverlight animations
      4m 25s
    2. Creating animations
      4m 59s
    3. Controlling animations
      5m 18s
    4. Simulating physics with animation easings
      3m 43s
    5. Create a custom easing
      3m 20s
  12. 32m 33s
    1. Placing XAML resources within a FrameworkElement
      4m 45s
    2. Centralizing settings in styles
      5m 20s
    3. Creating alternate control UI with ControlTemplates
      10m 32s
    4. Dressing up your data with DataTemplates
      4m 19s
    5. Explaining the VisualStateManager: A simple way to manage control state
      7m 37s
  13. 22m 25s
    1. Handling errors in a Silverlight application
      4m 46s
    2. Setting up application events
      3m 20s
    3. Reporting incremental progress with a loading screen
      6m 53s
    4. Storing data on the client
      7m 26s
  14. 22m 40s
    1. Exploring the Expression Blend asset pane
      4m 26s
    2. Adding behaviors to elements with Blend Behaviors
      5m 2s
    3. Creating custom behaviors
      3m 24s
    4. Using the built-in shader effects
      3m 56s
    5. Creating custom shaders
      5m 52s
  15. 1m 1s
    1. Goodbye
      1m 1s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Silverlight 3 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.