Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Microsoft Silverlight 5 is a rich application framework for creating high-performance, cross-platform desktop and mobile applications. In this course, author Walt Ritscher demonstrates how to build a variety of applications in Silverlight, with particular focus on building compelling business applications and delivering premium video and audio content. Developers will work with the C# programming language and Visual Studio Professional, as well as Expression Blend, a tool that simplifies creation of the interactive user interfaces expected in modern-day applications.
Each language or platform that you learn has its quirks and oddities. Silverlight is no different in that respect. In this movie, I want to address a few scenarios that are common is Silverlight and require special debugging techniques. The three demos that I want to show are listed here. You will find these inside the SpecialDebugging project if you have the Exercise Files. I have opened SpecialDebugging and then I have opened the MainPage.xaml and switched to the Code View. The three demos I want to do today are Attach to Process, Asynchronous Programming, and the Thread window and Macintosh debugging.
This first scenario, I want to launch the Chrome browser, and then attach Visual Studio's debugger to it. I will start by pressing F5. On this computer, I have IE set as my default browser. I will copy this link, and then I'll open the Chrome browser, and paste in that link. Now, I have got two browsers, both asking for pages for my Development server. I'll switch back to Visual Studio and choose the Debug menu, and then I'll choose Attach to Process.
I am going to attach to this Chrome instance right here, the one that says Silverlight. I will choose Attach. For today's demo, I am going to add a breakpoint in this Button_Click procedure. I will press F9, then I'll switch back to the Chrome browser and click on Async Debugging button. And as you can see, I'm now debugging that Chrome browser. For my next demo, I want to look at Asynchronous Debugging and the Thread Window. Many times in Silverlight, you want to do an asynchronous call to get data to pull into your Silverlight application.
You don't want to block your UI thread, so you spawn a worker thread to do the work. My example I'm using here is going to get an RSS feed. I'm doing that by using the HTTPWebRequest, pointing it to a feed URL, and then I'm calling this BeginGetResponse. That will cause a worker thread to be sent out to process on this function here, ResponseCallback. To see the threads in Visual Studio, you can choose the Debug menu, then Windows, and then Threads.
This shows currently that I have a Chrome executable running and an Internet Explorer executable running, and the main thread that's processing the request inside the Chrome browser is 4128. It's my main thread. Now, hide that temporarily. The second function down here should be running on a worker thread. So I need to put a second breakpoint in here, and then, I'm going to go ahead, and press F5 to run the application. Now, I'll hit my second breakpoint. So I open the Threads window again, you will see I am now on a worker thread. Now, I am on 3400.
I have got some code in here that pulls the result back from the WebRequest, loads it into a stream, creates an XML reader, creates a syndication feed, and then this little bit of code here is returning back to the UI thread to update the feed list box. Since it's a UI control, it must be called on the UI thread. So if I put a breakpoint in here, and then press F5 to continue, and then go look at my Thread window, you will see that I'm back on the main thread 4128.
Next, I want to talk about Remote Debugging on a Mac. The first step for Remote Debugging on a Mac is easy. On your Developer Computer, install Visual Studio. Acquire a Mac, and install the Silverlight Developer Runtime. It's important to have the special runtime, not the standard runtime seen in the most consumer computers. Ensure that you have both computers in a common network, and that, that network permission allows file transfers between the two machines. You want to start Visual Studio on the PC, and on the Mac, you want to launch the Silverlight application.
Then, on the PC, you'll want to run a tool called the Silverlight Cross Platform Debugger. Using that tool, you want to find the remote computer and attach to the remote process. That is similar to what I just showed you in this video. If you want to know more about Remote Debugging, get the details at this URL. Debugging and Testing are a crucial part of real-world development, but with the tips I've shown you in this movie, you are well on your way to becoming a Debugging prodigy.
Find answers to the most frequently asked questions about Silverlight 5 Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.