+ All Categories
Home > Documents > Session 15_TP 8.ppt

Session 15_TP 8.ppt

Date post: 06-Jan-2016
Category:
Upload: hocvien-daotao
View: 222 times
Download: 0 times
Share this document with a friend
Popular Tags:

of 50

Transcript
  • Debug, Test and Deploy ApplicationsSession 8

  • ReviewSystem.IO namespace has classes that facilitate reading and writing of data to data streams and files.The BinaryReader and BinaryWriter classes are derived from System.Object. BinaryReader is the class that is used for reading binary data. The BinaryWriter class is employed for writing binary data from a C# variable to a specified stream.The Stream class is an abstract class from which different classes such as FileStream and MemoryStream classes are derived.The NetworkStream class that resides within the System.Net.Sockets namespace is used to send and receive data across the network.The CryptoStream class is used to link the stream of data to any cryptography object for the purpose of encrypting the data.

  • Review ContdThe Directory class contains static methods that help in handling directories and subdirectories. The File class contains static methods that help in handling files. It also helps in the creation of FileStream class.The FileSystemInfo Class is an abstract class from which the FileInfo and DirectoryInfo classes are derived. The TextReader is the abstract base class for the StreamReader and StringReader classes. The StreamReader reads a character in a byte stream and converts to the specified encoding. The StringReader class is used to read data from an input string.The TextWriter is the abstract base class for classes that can be used to write sequential characters. The StreamWriter class writes characters to a stream in a specified encoding. The StringWriter class is used to write data to a string.

  • ObjectivesDiscuss how to debug and troubleshoot applicationsDiscuss how to test C# applicationsDiscuss deployment conceptsDiscuss deploying of applicationsExplore deployment alternativesCreate a sample application, package and deploy it

  • DebuggingThe process of searching and eliminating bugs or errors in applications is calledAn application that has been developed, tested and debugged is ready for deployment to client machines

  • Need for debuggingHelps locate and resolve bugsReduces time, effort and cost to maintain the application in the long run Syntax Errors Logical/Semantic Errors

  • Syntax ErrorsWrong syntax of C# statementsMissing braces, semicolons, spelling mistakes, missing statements, etc Identified during compile-time They can be easily identified and corrected

  • Logical/Semantic ErrorsInfinite loops, reading files that do not exist, wrong calculations etc Using objects that do not have values assigned to themIdentified during execution of the program Debugging these is difficult as they arise only during application run-time

  • Debugging ProcedureMost programming languages and tools provide debuggers that enable programmers to observe the run-time behavior of a program, track values of variables and identify the location of semantic errors. Visual Studio .NET also provides a debugger that the programmer can use to debug code written in one of the .NET supported languages While using the debugger, a breakpoint can be inserted in the code to halt its execution at that particular line. At this point, the program enters the break mode and is said to be in a suspended state.In the break mode, the programmer can check the values of variables change them if required and also check other data.

  • Breakpoints

  • Compile and Build Applications in VS.NETThere are two modes in which applications can be compiled and built Debug ModeUsed to repeatedly compile and troubleshoot an application until it becomes successful and running. Release ModeUsed when the application will not be repeatedly compiled and is ready for release.

  • VS.NET Debugging ToolsSome debugging tools provided by VS.NETLocals windowWatch window QuickWatch dialog boxImmediate window

  • Locals WindowDisplays the values present in the local variables Lists only the variables that are within the current scope and tracks their values

  • Watch WindowUsed to evaluate variables, expressions and track their values through the program as the program executes

    It can also be used to edit the value of a variable

    The variables that are to be watched should be provided or indicated by the developer

    Several watch windows can be simultaneously opened to check for several expressions or variables at the same time

  • QuickWatch Dialog BoxUsed to quickly evaluate a variable or expression as well as to modify the value of the variable

    Used to display values for only one variable at a time.

    Modal in nature

    Cannot be used to track the values of a variable in the course of execution

  • Immediate WindowUsed for checking the value of a variable, for assigning a value to a variable as well as to run a line of code

    The name of the variable has to be prefixed with a question mark in order to find its value

    The value of a variable can be changed by keying in the code for the assignment within the Immediate window, and pressing Enter.

  • TestingAny application needs to be tested with various kinds of data to ensure that it is fully functional and working It is the process of inspecting an application and ensuring that it meets the specifications for which it was designed Testing should be done from the point of view of finding out more and more errors in an application.

  • Types of TestingPopular techniques used for testing include

  • Unit TestingIsolates the smallest module or unit from the rest of the application and tests it

    Modules are formed as drivers and stubs. A driver is a simulation of a calling unit and a stub is a simulation of a called unit Consumes time, effort and money but is highly beneficial Scrutinizing every unit results in improving the quality of the application and chances of errors being discovered later on are reduced

  • Integration testingIn Integration testing, two or more units can be merged and then tested to see if they function correctly.There are 3 commonly used methods for implementing integration testing: Top down approachBottom-up approachUmbrella approach

  • Performance TuningPerformance of an application plays a major role in terms of client satisfaction In performance management, one of the main activities performed is performance tuning as it helps fine-tune the application to the needs of the clients Helps to identify and resolve bottlenecks that may be leading to the poor performance of the application The Performance Tuning cycle involves 4 steps: CollectingAnalyzingConfiguringTesting

    text

    text

    Collecting

    Analyzing

    Configuring

    Testing

    Performance Tuning Cycle

  • Performance AnalysisPerformance Analysis analyzes the performance of an application for likely problems and ensures that the software meets or surpasses the design intentions or expectations. Microsoft Visual Studio Analyzer is a tool that works with the .NET framework to assist us in determining which component is not functioning properly and conduct performance analysis.Code profiling tools, such as the Microsoft Source Profiler, help to understand exactly where a component or single-process application is spending its execution time

  • Packaging and DeploymentThe term packaging means building up all the files in the application into a single file called a Distribution Unit

    The process of distributing a completed application or component and installing it on the client computers is called Deployment.

    Before deployment, we need to decide on what to deploy, where to deploy and how to deploy.

  • Deployment TasksAdd a deployment project to a solutionSet properties for the deployment projectAdd files and other components

    Specify the location for installing files on the client machineSpecify settings for the registry on the clients machineSpecify the user interface that will be displayed during installationSpecify the actions that need to be performed during installationSpecify conditions of installation

    MandatoryOptional

  • Modes of PackagingInstaller files (using Microsoft Windows Installer)Shipped along with Windows 2000, Windows ME and Windows XP as an installation and configuration service Creates msi files for use with the Windows Installer or with some other installer CAB file projectAllow ActiveX controls that are downloaded from a Web server, to be compressed and packaged into .cab (Cabinet) files. These .cab files make distribution or download less time consuming. A third method of packaging would be to simply use the .dll or .exe files as they were built.

  • Deployment ScenariosEither focus on single machine deployment or multiple machine deployment A single machine installation provides a simple way to deploy and interact with the sample. The various multiple machine installations provide the ability to research different scenarios The requirements for creating and installing assemblies are relatively minimal, whether we choose to develop applications with private assemblies or with strong-named assemblies Security considerations can also affect how applications are deployed

  • Deployment AlternativesThere are various approaches to deploy an application in .NET.

    XCOPY Command

    Windows Installer 2.0

    Code Download

  • XCOPY CommandA DOS command that can be used to copy the application to the appropriate directory Easiest way to install an application.Un-installing the application can be done by deleting the directory structure of the application.Installs private and strong-named assemblies only

  • Options of XCopy commandOptionDescription/pPrompts us to confirm whether we want to create eachdestination file./qSuppresses display of XCOPY messages./eCopies all subdirectories, even if they are empty./sCopies directories and subdirectories, unless they are empty. If we omit this option, XCOPY works within a single directory.

  • Windows Installer 2.0Windows Installer 2.0 can install, repair, or remove Microsoft .NET Framework assemblies in the Global Assembly Cache and in private directories A Visual Studio .NET setup project can be used to build a .msi file, which acts as a database that stores all instructions and data required for installation and un-installation.Enforces installation rules that help to prevent conflicts with shared resources between existing applications.It allows a Rollback of unsuccessful installations, repairs, or removals of assemblies.

  • Code DownloadWhen an application is to be distributed over the Internet or through a corporate intranet, the code can be downloaded to a computer and the application can be executed This method is efficient for distributing Compressed .CAB files and windows form controls.

  • Deploying a simple application1. Create a console based application using the code given belowusing System;using System.Collections;namespace CalculateArea{ class Area { private int areaVal; public void AreaCal(int radius) {areaVal = (22/7)* radius*radius; } public void AreaCal(int length, int breadth) {areaVal = length*breadth; }

  • Deploying a simple application Contdpublic void AreaCal(int length, int breadth, int height){ areaVal = length*breadth*height;}[STAThread]static void Main(string[] args){ int radius = 0; int len = 0; int breadth = 0; int height = 0; Area newArea = new Area(); Console.WriteLine ("Enter radius"); radius = Int32.Parse(Console.ReadLine()); newArea.AreaCal(radius);

  • Deploying a simple application-ContdConsole.WriteLine ("Area with radius provided is {0}",newArea.areaVal); Console.WriteLine("\nEnter length");len = Int32.Parse(Console.ReadLine());Console.WriteLine("\nEnter breadth");breadth = Int32.Parse(Console.ReadLine());Console.WriteLine("\nEnter height");height = Int32.Parse(Console.ReadLine());newArea.AreaCal (len,breadth,height);Console.WriteLine ("Area with length, breadth and height provided is {0}",newArea.areaVal);newArea.AreaCal(len,breadth);Console.WriteLine ("Area with length and breadth provided is {0}",newArea.areaVal);Console.ReadLine(); } }}

  • Deploying a simple applicationContd2. Create a new deployment project by selecting File New Project.3. Select Setup and Deployment Projects from the Project Types list and select Setup Project from the list of Templates provided

  • Deploying a simple applicationContdChange the project name to AreaSetup and select the application Folder node of the File System Editor

  • Deploying a simple applicationContd5. Select Action -> Add -> File6. Select the .exe file CalculateArea.exe

  • Deploying a simple applicationContd7. select the .exe file just added and Click Action Create shortcut to [ApplicationName].Exe option. Notice that a Shortcut to the application CalculateArea.exe is added

  • Deploying a simple applicationContd8. Drag and drop this shortcut file to the Users Desktop folder on the left hand pane of the editor. This adds the file to the Users Desktop folder

  • Deploying a simple applicationContd9. Select the .exe file from the Application Folder in the File System Editor. Select Action Create shortcut to CalculateArea.exe and create another shortcut to the application.

    10. Follow the procedure mentioned in Step 9 to add this new shortcut to the Users Program Menu folder.

    11. Click on View Editor Launch Conditions

  • Deploying a simple applicationContd12. Select Requirements on Target Machine node and click on Action Add File Launch Condition

    13. Rename the Search for File1 node to Search for Internet Explorer and Right Click on Search for Internet Explorer to invoke the Properties Window. Set the FileName property to Iexplore.exe.

    14. Set the Folder property to [ProgramFilesFolder], Depth property to 2, MinVersion property to 5.0 and Property property to IEFILEXISTS

  • Deploying a simple applicationContd

  • Deploying a simple applicationContd15. Select the Condition1 node and open its Properties window. Set its Condition property to IEFILEXISTS . Set the Message property to Internet Explorer 5.0 or higher version not found

  • Deploying a simple applicationContd16. Select the deployment project and on the View menu, click Property Pages 17. Select Windows Installer Bootstrapper option from the Bootstrapper drop down options

  • Deploying a simple applicationContd18. Select AreaSetup in the Solution Explorer and select Build Build AreaSetup from the menu As a result of all the steps executed, the start up project is created and is ready for distribution and installation in any system. Setup.exe is one of the files that is included in the files that are added to the Debug folder of the deployment project and it acts as an entry point for the installation process

  • Installing the ApplicationStart Windows Explorer and browse to the folder containing the setup project. This would be in the Debug folder of the AreaSetup folder on the system.From the Edit Menu select Select All option.Copy these files into another directory of the same computer or any other target computer where the application is to be installed.In the Target machine, at the location where the files are copied, click on the Setup.exe file.Windows Installer will start the Application Setup Wizard. Follow the directions provided by the Windows Installer.Once the installation is complete, locate the shortcut, Shortcut to CalculateArea.exe on the Desktop. Double-click the shortcut to open the application

  • Installing the Application

  • Output of CalculateArea.exe

  • SummaryThe process of searching and eliminating each error or bug is called debugging.The Visual Studio.NET environment provides means to create, compile and build application solutions. There are two modes in which applications can be built:Debug modeRelease modeThe Locals window displays the values present in the local variables. The Watch window is used to evaluate variables and expressions and track their values through the program. The QuickWatch dialog box can be used to quickly evaluate a variable or expression.The Immediate window can be used for checking the value of a variable, for assigning a value to a variable as well as to run a line of code.Testing large applications can be done using techniques such as unit testing and integration testing.

  • Summary ContdPerformance tuning helps fine-tune the application to the needs of the clients, identifies and resolves bottlenecksPerformance Analysis analyzes the performance of an application for likely problems and ensures that the software meets or surpasses the design intentions or expectations. Microsoft Visual Studio Analyzer is a tool that works with the .NET framework to assist us in determining which component is not functioning properly.The term packaging means building up all the files in the application into a single file called a Distribution Unit. And the process of distributing a completed application or component and installing it on the client computers is called Deployment. Deployment in VS.NET is based on Microsoft Windows Installer technologyXCOPY, Windows Installer 2.0 and Code download are various approaches to deploy an application in .NET.


Recommended