MSDN Magazine - January 2009 - (Page 33) Another point that is worth noting is that it is the original XAP content, including assemblies and XAML, that is cached. Therefore, the running application can programmatically modify the original XAML. However, such changes won’t be cached automatically, and likewise, any resource you may extract from a XAP package (media, images, and so on) is not cached separately. Thus, whenever the user visits the page, the XAP package is not downloaded again (unless it is expired), but any resources will be extracted again. Furthermore, any changes you may have made to these resources in previous sessions are lost. To persist changes to the XAML document object model, you have to arrange your own tailor-made cache. (This is a cool technique that I will cover in Part 2 of this topic.) Finally, note that the XAP package saved in the browser’s cache is at the mercy of the user. Should the user decide to clear the cache at some time, anything located there will be lost—including your XAP packages. To permanently store Silverlight XAP packages, you have to resort to isolated storage (this topic is also slated for Part 2). Guerrilla .NET: w/ 3.0 & 3.5 content November 3rd-7th London Call 800.699.1932 to register today! or visit www.develop.com Guerrilla .NET w/3.0 & 3.5 content LOS ANGELES February 16–20 New Hands-on .NET 3.0/3.5 Training Upcoming Courses What’s New in .NET 3.0-3.5 w/LINQ What’s New in .NET 3.0-3.5 featuring LINQ DALLAS 6th - Boston OctoberFebruary 23-27 BOSTON March 2-6 A Tool for Downloads When you write Silverlight applications, remember that every resource you need that is not already packed in the application’s XAP must be explicitly downloaded from the server. The WebClient class is the primary Silverlight tool you want to use to arrange downloads of additional resources. The class provides a few asynchronous methods for sending data to, and receiving data from, a Web resource. Here’s how it works: WebClient wc = new WebClient(); wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(callback); wc.DownloadStringAsync(address); Windows Communication Foundation Essential LINQ with w/ 3.5 content the Entity Framework October 13th - Los Angeles November 3rd- Chicago Essential Silverlight 2 November 17th- New York DALLAS January 19–22 LOS ANGELES Presentation Foundation WindowsFebruary 24–27 LOS ANGELES January 27–30 w/ 3.5 content Enhancing Web October 13th - Development with .NET 3.5 Los Angeles LOS ANGELES February 9–12 November 10th - Austin Essential Windows Presentation Foundation Windows WorkFlow Foundation CHICAGO February 23–27 November 3rd - Los Angeles LOS ANGELES March 2-6 BOSTON February 2–6 The DownloadStringAsync method operates an HTTP GET and captures the URL response as a string. The string is received by the associated callback, as shown here: void callback(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) return; string response = e.Result; } NEW COURSE Essential F# Learn to create reliable software on the .NET framework Business Intelligence Learn to leverage the power of Microsoft’s BI platform Essential Skills for the Business Analyst New Courses October 29th - Los Angeles On-Site Training As you’ll see in a moment, this method is perfect for downloading plain XAML with no attached codebehind. To programmatically download binary data, such as a XAP package, you need a stream and a slightly different approach. The WebClient class is still helpful, as it provides an apt method in OpenReadAsync: WebClient wc = new WebClient(); wc.OpenReadCompleted += new OpenReadCompletedEventHandler(callback); wc.OpenReadAsync(address); Essential OSLO Learn how OSLO can be used to create model driven apps Essential AZURE For groups of students, DevelopMentor’s Learn how to develop scalable AZURE hosted applications On-Site course delivery may offer the CALL most800.699.1932 FOR MORE INFORMATION. cost-effective solution – at your location, at the time you need it. OnOn-Site Training For Groups! Sites also offer the ability to customize a For group’s of students, DevelopMentor’s On-Site course course to your group’s needs, including delivery may offer the most cost-effective solution—at course content, labsneed it. run on your that On-Sites also offer your location, at the time you programming platform and needs,exercises the ability to customize a course to your lab including course content, labs that run on your or project. tailored to your business programming platform and lab exercises tailored to your business or project. CALL US TODAY TO DISCUSS YOUR TRAINING NEEDS Call us today to discuss your training needs! The structure of the associated callback is the same in the previous case. In the end, you use the DownloadStringAsync method to get a simple string; you use the OpenReadAsync method to get a stream of any data. Whether you decide to download a string or a stream is mostly a matter of preference and depends essentially on how you plan to use the data you’re receiving. Note also that WebClient provides a pair of methods for writing to a remote URL: UploadStringAsync for posting a string and msdnmagazine.com US -800.699.1932 UK -(0)8000.562.265 Developing people software Europe-(0)01242.525.108who develop January 2009 33 http://develop.com http://www.develop.com http://develop.com http://www.msdnmagazine.com
Table of Contents Feed for the Digital Edition of MSDN Magazine - January 2009 Toolbox CLR Inside Out Basic Instincts Cutting Edge Test Run First Look Geneva Framework Silverlight Windows Mobile Service Station Security Briefs Extreme ASP.NET Foundations .NET Matters { End Bracket } MSDN Magazine - January 2009 MSDN Magazine - January 2009 - (Page Intro) MSDN Magazine - January 2009 - (Page Cover1) MSDN Magazine - January 2009 - (Page Cover2) MSDN Magazine - January 2009 - (Page 1) MSDN Magazine - January 2009 - (Page 2) MSDN Magazine - January 2009 - (Page 3) MSDN Magazine - January 2009 - (Page 4) MSDN Magazine - January 2009 - (Page 5) MSDN Magazine - January 2009 - (Page 6) MSDN Magazine - January 2009 - (Page 7) MSDN Magazine - January 2009 - (Page 8) MSDN Magazine - January 2009 - Toolbox (Page 9) MSDN Magazine - January 2009 - Toolbox (Page 10) MSDN Magazine - January 2009 - Toolbox (Page 11) MSDN Magazine - January 2009 - Toolbox (Page 12) MSDN Magazine - January 2009 - Toolbox (Page 13) MSDN Magazine - January 2009 - Toolbox (Page 14) MSDN Magazine - January 2009 - CLR Inside Out (Page 15) MSDN Magazine - January 2009 - CLR Inside Out (Page 16) MSDN Magazine - January 2009 - CLR Inside Out (Page 17) MSDN Magazine - January 2009 - CLR Inside Out (Page 18) MSDN Magazine - January 2009 - CLR Inside Out (Page 19) MSDN Magazine - January 2009 - CLR Inside Out (Page 20) MSDN Magazine - January 2009 - Basic Instincts (Page 21) MSDN Magazine - January 2009 - Basic Instincts (Page 22) MSDN Magazine - January 2009 - Basic Instincts (Page 23) MSDN Magazine - January 2009 - Basic Instincts (Page 24) MSDN Magazine - January 2009 - Basic Instincts (Page 25) MSDN Magazine - January 2009 - Basic Instincts (Page 26) MSDN Magazine - January 2009 - Basic Instincts (Page 27) MSDN Magazine - January 2009 - Basic Instincts (Page 28) MSDN Magazine - January 2009 - Basic Instincts (Page 29) MSDN Magazine - January 2009 - Basic Instincts (Page 30) MSDN Magazine - January 2009 - Cutting Edge (Page 31) MSDN Magazine - January 2009 - Cutting Edge (Page 32) MSDN Magazine - January 2009 - Cutting Edge (Page 33) MSDN Magazine - January 2009 - Cutting Edge (Page 34) MSDN Magazine - January 2009 - Cutting Edge (Page 35) MSDN Magazine - January 2009 - Cutting Edge (Page 36) MSDN Magazine - January 2009 - Cutting Edge (Page 37) MSDN Magazine - January 2009 - Cutting Edge (Page 38) MSDN Magazine - January 2009 - Test Run (Page 39) MSDN Magazine - January 2009 - Test Run (Page 40) MSDN Magazine - January 2009 - Test Run (Page 41) MSDN Magazine - January 2009 - Test Run (Page 42) MSDN Magazine - January 2009 - Test Run (Page 43) MSDN Magazine - January 2009 - Test Run (Page 44) MSDN Magazine - January 2009 - Test Run (Page 45) MSDN Magazine - January 2009 - Test Run (Page 46) MSDN Magazine - January 2009 - Test Run (Page 47) MSDN Magazine - January 2009 - Test Run (Page 48) MSDN Magazine - January 2009 - Test Run (Page 49) MSDN Magazine - January 2009 - First Look (Page 50) MSDN Magazine - January 2009 - First Look (Page 51) MSDN Magazine - January 2009 - First Look (Page 52) MSDN Magazine - January 2009 - First Look (Page 53) MSDN Magazine - January 2009 - First Look (Page 54) MSDN Magazine - January 2009 - First Look (Page 55) MSDN Magazine - January 2009 - First Look (Page 56) MSDN Magazine - January 2009 - First Look (Page 57) MSDN Magazine - January 2009 - First Look (Page 58) MSDN Magazine - January 2009 - First Look (Page 59) MSDN Magazine - January 2009 - First Look (Page 60) MSDN Magazine - January 2009 - First Look (Page 61) MSDN Magazine - January 2009 - First Look (Page 62) MSDN Magazine - January 2009 - First Look (Page 63) MSDN Magazine - January 2009 - Geneva Framework (Page 64) MSDN Magazine - January 2009 - Geneva Framework (Page 65) MSDN Magazine - January 2009 - Geneva Framework (Page 66) MSDN Magazine - January 2009 - Geneva Framework (Page 67) MSDN Magazine - January 2009 - Geneva Framework (Page 68) MSDN Magazine - January 2009 - Geneva Framework (Page 69) MSDN Magazine - January 2009 - Geneva Framework (Page 70) MSDN Magazine - January 2009 - Geneva Framework (Page 71) MSDN Magazine - January 2009 - Geneva Framework (Page 72) MSDN Magazine - January 2009 - Geneva Framework (Page 73) MSDN Magazine - January 2009 - Geneva Framework (Page 74) MSDN Magazine - January 2009 - Silverlight (Page 75) MSDN Magazine - January 2009 - Silverlight (Page 76) MSDN Magazine - January 2009 - Silverlight (Page 77) MSDN Magazine - January 2009 - Silverlight (Page 78) MSDN Magazine - January 2009 - Silverlight (Page 79) MSDN Magazine - January 2009 - Silverlight (Page 80) MSDN Magazine - January 2009 - Silverlight (Page 81) MSDN Magazine - January 2009 - Silverlight (Page 82) MSDN Magazine - January 2009 - Silverlight (Page 83) MSDN Magazine - January 2009 - Silverlight (Page 84) MSDN Magazine - January 2009 - Silverlight (Page 85) MSDN Magazine - January 2009 - Silverlight (Page 86) MSDN Magazine - January 2009 - Silverlight (Page 87) MSDN Magazine - January 2009 - Windows Mobile (Page 88) MSDN Magazine - January 2009 - Windows Mobile (Page 89) MSDN Magazine - January 2009 - Windows Mobile (Page 90) MSDN Magazine - January 2009 - Windows Mobile (Page 91) MSDN Magazine - January 2009 - Windows Mobile (Page 92) MSDN Magazine - January 2009 - Service Station (Page 93) MSDN Magazine - January 2009 - Service Station (Page 94) MSDN Magazine - January 2009 - Service Station (Page 95) MSDN Magazine - January 2009 - Service Station (Page 96) MSDN Magazine - January 2009 - Service Station (Page 97) MSDN Magazine - January 2009 - Service Station (Page 98) MSDN Magazine - January 2009 - Security Briefs (Page 99) MSDN Magazine - January 2009 - Security Briefs (Page 100) MSDN Magazine - January 2009 - Security Briefs (Page 101) MSDN Magazine - January 2009 - Security Briefs (Page 102) MSDN Magazine - January 2009 - Extreme ASP.NET (Page 103) MSDN Magazine - January 2009 - Extreme ASP.NET (Page 104) MSDN Magazine - January 2009 - Extreme ASP.NET (Page 105) MSDN Magazine - January 2009 - Extreme ASP.NET (Page 106) MSDN Magazine - January 2009 - Extreme ASP.NET (Page 107) MSDN Magazine - January 2009 - Extreme ASP.NET (Page 108) MSDN Magazine - January 2009 - Foundations (Page 109) MSDN Magazine - January 2009 - Foundations (Page 110) MSDN Magazine - January 2009 - Foundations (Page 111) MSDN Magazine - January 2009 - Foundations (Page 112) MSDN Magazine - January 2009 - Foundations (Page 113) MSDN Magazine - January 2009 - Foundations (Page 114) MSDN Magazine - January 2009 - Foundations (Page 115) MSDN Magazine - January 2009 - .NET Matters (Page 116) MSDN Magazine - January 2009 - .NET Matters (Page 117) MSDN Magazine - January 2009 - .NET Matters (Page 118) MSDN Magazine - January 2009 - .NET Matters (Page 119) MSDN Magazine - January 2009 - { End Bracket } (Page 120) MSDN Magazine - January 2009 - { End Bracket } (Page Cover3) MSDN Magazine - January 2009 - { End Bracket } (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.