1、Exercise 1: Using IntelliTrace in Production 4Exercise 2: Debugging with IntelliTrace Files from Production 10OverviewIntelliTrace first released in Visual Studio 2010 changed the game for debugging by allowing developers to step “back in time” to see how an application got into its current state. B
2、y exposing events such as file and registry access, exceptions, and method calls, an IntelliTrace file can provide a detailed view into application behavior. In this lab, you will learn how Visual Studio 11 will extend the capabilities of IntelliTrace beyond the development and testing organizations
3、 by providing IT administrators with the ability to capture IntelliTrace files running from production servers. These files can then be analyzed by developers to help diagnose production issues.PrerequisitesIn order to complete this lab you will need the Visual Studio 11 virtual machine provided by
4、Microsoft. For more information on acquiring and using this virtual machine, please see this blog post.About the Fabrikam Fiber ScenarioThis set of hands-on-labs uses a fictional company, Fabrikam Fiber, as a backdrop to the scenarios you are learning about. Fabrikam Fiber provides cable television
5、and related services to the United States. They are growing rapidly and have embraced Windows Azure to scale their customer-facing web site directly to end-users to allow them to self-service tickets and track technicians. They also use an on-premises ASP.NET MVC application for their customer servi
6、ce representatives to administer customer orders.In this set of hands-on labs, you will take part in a number of scenarios that involve the development and testing team at Fabrikam Fiber. The team, which consists of 8-10 people, has decided to use Visual Studio application lifecycle management tools
7、 to manage their source code, run their builds, test their web sites, and plan and track the project. ExercisesThis hands-on lab includes the following exercises:1. Using IntelliTrace in Production2. Debugging with IntelliTrace Files from ProductionEstimated time to complete this lab: 60 minutes. Us
8、ing IntelliTrace in ProductionIn this exercise, you will learn how to deploy and use IntelliTrace in Production to capture trace information for an ASP.NET application.3. Log in as Adam. All user passwords are P2ssw0rd.4. Launch Internet Explorer and click on the FF Customer Portal button in the fav
9、orites bar to load the customer portal for Fabrikam Fiber Support ().Figure 1Fabrikam Fiber customer portal5. Select a few of the service tickets from the My Tickets section of the page to view their details until you come across one that indicates that an error occurred retrieving data from the ser
10、ver. This information is ultimately pulled from a database, but there could be any number of reasons for the general error message itself.Figure 2Error message shown when selecting service ticket6. Close Internet Explorer.7. Typically, the first step in determining the root cause of an error like th
11、is would be to check logs for details and perhaps a stack trace. If that does not provide enough information, and the error is not easily reproduced in a development environment, the development team may end up taking a long time to determine the root cause and fix the problem. Installing Visual Stu
12、dio or other debugging tools in a production environment may not be an option.8. Now lets look at how to deploy and use IntelliTrace in a production environment to collect historical debugging data. Open a Windows Explorer window and navigate to the root of the C: drive. Note that there are two fold
13、ers here that were created ahead of time for our use in this lab, c:IntelliTrace is where the standalone IntelliTrace files are placed and c:LogFileLocation is where the IntelliTrace files will be written to later on in this lab.Figure 3Location of IntelliTrace files folder and log file folder9. In
14、an Explorer window, right-click on the LogFileLocation folder and select Properties to open the Properties window. We need to make sure that the IIS application pool has permission to use the LogFileLocation folder.10. Select the Security tab and then scroll down the existing list of groups and user
15、 names to find FabrikamFiber.Extranet.Web. Permissions were added ahead of time in this VM, but in a production environment, you would need to make sure to perform this step yourself. Figure 4Setting security to enable log files to be written11. Press the Escape key to exit out of the properties win
16、dow.12. IntelliTrace can be deployed to a production environment simply by extracting the contents of the IntelliTraceCollection.cab file that ships with Visual Studio 11. This task has also been performed ahead of time in the VM for your convenience, so there is no need for you to perform this step
17、.Figure 5Extracted contents of IntelliTraceCollection.cab fileNote: For the purposes of this lab, the production system is the same as our development system, but that will not normally be the case.13. Open a PowerShell window and type the following command to import the IntelliTrace PowerShell modu
18、le:Import-Module c:IntelliTraceMicrosoft.VisualStudio.IntelliTrace.PowerShell.dll14. To see the commands provided by IntelliTrace, using the following PowerShell command:Get-Command *IntelliTrace*Figure 6Searching for commands that contain “IntelliTrace” Commands are provided to start and stop an In
19、telliTrace collection, as well as to take checkpoints during collection. 15. To get help for any of the PowerShell IntelliTrace commands, type something like the following:Get-Help Start-IntelliTraceCollectionFigure 7Help screen for the Start-IntelliTraceCollection command The REMARKS section from t
20、he help listing describes how you can get more detailed examples of command usage.16. We are now ready to start IntelliTrace collection. Type the following PowerShell command to start collecting data from the FabrikamFiber.Extranet.Web IIS application pool and store the resulting .iTrace log files i
21、n the folder we previously created.Start-IntelliTraceCollection FabrikamFiber.Extranet.Web c:IntelliTracecollection_plan.ASP.NET.trace.xml c:LogFileLocation In the Visual Studio 11 Developer Preview, you can hand-edit the collection plan file if you want to make changes. A graphical editor is expect
22、ed to be provided in a later release.17. When asked to confirm, type “Y” and then press the Enter key to continue.Figure 8Confirming the request to start a collection18. Launch Internet Explorer and click on the FF Customer Portal button in the favorites bar to load .19. IntelliTrace is now setup to
23、 gather the debugging data specified in the collection plan configuration file. Select the service tickets to reproduce the error that we saw before. As soon as you see the error, close Internet Explorer.Figure 9Reproducing the error20. Return to the PowerShell window and type the following command
24、to get the current collection status.Get-IntelliTraceCollectionStatus -ApplicationPool Figure 10Collection status21. Type the following command to stop gathering IntelliTrace data for the FabrikamFiber.Extranet.Web application pool. Confirm the action when prompted.Stop-IntelliTraceCollection As an
25、alternative to stopping an IntelliTrace collection, it is also possible to get a copy of the current log by using the Checkpoint-IntelliTraceCollection command. This allows you to look at the data you have captured so far while continuing to collect additional data.22. In a real-world scenario, it i
26、s at this point that the IntelliTrace file would be sent to a developer or tester for a more detailed look. Debugging with IntelliTrace Files from ProductionIn this exercise, you will see how we can use the IntelliTrace file that was generated on a production server to aid in debugging the error tha
27、t we saw in the previous exercise.23. Returning to our scenario, lets assume that we have already taken this IntelliTrace file and transferred it to a development machine that has Visual Studio 11 installed. Double-click on the IntelliTrace file to load it in Visual Studio 11.Figure 11Loading the In
28、telliTrace file24. In the IntelliTrace summary window, scroll down to the Exception Data section. Here you can see a grid showing all exceptions that occurred. By default, they are sorted by most recent event time to the oldest.Figure 12Exception Data section of IntelliTrace summary25. Select the la
29、st System.NullReferenceException found in the list, that is the technically the oldest or first one that was thrown, and then select the Start Debugging button to start an IntelliTrace debugging session.Figure 13Start debugging at a specific event26. After the IntelliTrace debugging session starts,
30、you will see that the IntelliTrace pane is automatically loaded and the location in code where the exception occurred is highlighted. You now have full access to the normal suite of IntelliTrace debugging functionality.Figure 14Debugging the thrown exception27. In the Locals window, note that the Se
31、rviceTicket.AssignedTo property currently has a null value. This explains why referencing serviceTicket.AssignedTo.FullName in code resulted in the null reference exception that we saw. At this point, we could file a bug in Team Foundation Server and attach the IntelliTrace file to help the development team make the appropriate fix.Figure 15Finding root cause for exceptionTo gi
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1