Using Visual Studio.NET: IntelliSense and Debugging

Similar documents
Supplement: Visual C++ Debugging

The NetBeans Debugger: A Brief Tutorial

Computer Science II Lab 3 Testing and Debugging

Chapter 1: Getting Started

A Tutorial for ECE 175

Visual Studio.NET. Although it is possible to program.net using only the command OVERVIEW OF VISUAL STUDIO.NET

Microsoft Access 2016 Intro to Forms and Reports

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

MITOCW watch?v=se4p7ivcune

Intro to MS Visual C++ Debugging

BasicScript 2.25 User s Guide. May 29, 1996

Clickteam Fusion 2.5 Creating a Debug System - Guide

The Stack, Free Store, and Global Namespace

Arduino IDE Friday, 26 October 2018

MITOCW watch?v=zm5mw5nkzjg

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Laboratory Assignment #4 Debugging in Eclipse CDT 1

Tracking changes in Word 2007 Table of Contents

JCreator. Starting JCreator

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

Chapter 1 HMSL on the Macintosh

In this tutorial we are going to take a look at the CentovaCast 3 control panel running ShoutCast 2 and explain some of the basic features.

Chapter 1 Getting Started

The Domino Designer QuickStart Tutorial

Getting started 7. Setting properties 23

Introduction to IntelliJ

Contents. What's New. Version released. Newsletter #31 (May 24, 2008) What's New New version released, version 4.3.3

1 Getting used to Python

Creating and Simulate/Emulating an ASM Project in Atmel Introduction Procedure File New Project Assembler

Konark - Writing a KONARK Sample Application

Code::Blocks Student Manual

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

Getting started 7. Setting properties 23

The Filter Property Selecting a File The Save Menu The SaveFileDialog Control The Edit Menu The Copy Menu...

Post Experiment Interview Questions

Watch the video below to learn more about inspecting and protecting workbooks. *Video removed from printing pages

Emacs: the Free Software IDE

BEGINNER PHP Table of Contents

NEW CEIBO DEBUGGER. Menus and Commands

Lesson 1. Importing and Organizing Footage using Premiere Pro CS3- CS5

HOUR 4 Understanding Events

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Polygon Modeling Basics Chapter 1 - Vertices

Appendix J: Using Shortcut Keys and Shortcut Menus

Java Programming Constructs Java Programming 2 Lesson 1

ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW

1 of 11. TUTORIAL - Content Creator Plus (CCP) (for Trainz 2006) Written Aug. 21, By Jytte Christrup. HOW TO MAKE A SOUND FILE, Step by Step

GETTING STARTED WITH ECLIPSE Caitrin Armstrong

MITOCW watch?v=9h6muyzjms0

Azon Master Class. By Ryan Stevenson Guidebook #5 WordPress Usage

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

Note: Please use the actual date you accessed this material in your citation.

Advisor Answers. January, Visual FoxPro 3.0 and 5.0

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide

Prerequisites for Eclipse

Introduction to Computation and Problem Solving

COPYRIGHTED MATERIAL. Starting Strong with Visual C# 2005 Express Edition

Debugging Code in Access 2002

It could be worse - they could have required the Enterprise Edition, which is $1500 and up.

Proper Debugging of ATSAMD21 Processors

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

Get Your Game On. Getting and Installing PCSX. Getting Plugins and BIOS. Installing the "Easy Stuff" Playing PlayStation Games in Linux

ECE QNX Real-time Lab

Excel Skill Module. EPG Workshop. by T. A. Ebert M.E. Rogers

their in the new a program such as Excel or Links aren't just document.

Authoring Playground Books with Bluefruit for ios

Indispensable tips for Word users

Copied from: on 3/20/2017

Getting Started with Visual Basic.NET

PATTERN MAKING FOR THE PHOENIX HOOP

Module 1: Information Extraction

Debugging. CSE 2231 Supplement A Annatala Wolf

Intro To Excel Spreadsheet for use in Introductory Sciences

Lesson 1 using Dreamweaver CS3. To get started on your web page select the link below and copy (Save Picture As) the images to your image folder.

It s possible to get your inbox to zero and keep it there, even if you get hundreds of s a day.

Basic Fiction Formatting for Smashwords in OpenOffice L. Leona Davis. Copyright 2012 L. Leona Davis All Rights Reserved

Notes to Accompany Debugging Lecture. Jamie Blustein

MITOCW ocw f99-lec12_300k

An Introduction to Maple This lab is adapted from a lab created by Bob Milnikel.

Skill 1: Multiplying Polynomials

Fortunately, you only need to know 10% of what's in the main page to get 90% of the benefit. This page will show you that 10%.

2 Working with a Database

Heads Up Design: Focusing on the drawing area

Installation Guide ~ Visual Studio C Express Edition

Customizing Access Parameter Queries

Using X-Particles with Team Render

This paper was presented at DVCon-Europe in November It received the conference Best Paper award based on audience voting.

Introduction. Getting Started with Visual Basic Steps:-

static CS106L Spring 2009 Handout #21 May 12, 2009 Introduction

MITOCW MIT6_172_F10_lec18_300k-mp4

Linked Lists. What is a Linked List?

Molecular Statistics Exercise 1. As was shown to you this morning, the interactive python shell can add, subtract, multiply and divide numbers.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Click the buttons in the interactive below to learn more about using Mail view in Outlook 2010.

Try the program given above (inkey01.dbpro). If you're really lucky, you might display a character, but you'll have to be fast!

Using Microsoft Excel

Here we will look at some methods for checking data simply using JOSM. Some of the questions we are asking about our data are:

Programming Logic - Beginning

This chapter is intended to take you through the basic steps of using the Visual Basic

Centralized Log Hosting Manual for User

Transcription:

DRAFT Simon St.Laurent 3/1/2005 2 Using Visual Studio.NET: IntelliSense and Debugging Since you're going to be stuck using Visual Studio.NET anyway, at least for this edition of the.net Compact Framework, you might as well get familiar with some of the features it provides. A lot of the things in Visual Studio.NET are targeted at database development, Web development, and other projects very different from.net Compact Framework programming, but there are at least two features beyond the basic code entry and compilation which are well worth learning: IntelliSense, which helps you type correct code, and the debugging features, which can help you sort out what's going on when your program logic doesn't behave as expected. If you've used Visual Studio.NET before, this chapter may not be very exciting to you. Feel free to skip around. IntelliSense IntelliSense is a feature Microsoft provides to help you navigate through the evergrowing number of methods and parameters in their libraries and the code you write yourself. Thanks to IntelliSense, whenever you type an object or variable name it recognizes and type a period, you'll get a menu of choices that Visual Studio.NET thinks might be appropriate there. Type the first few letters, and IntelliSense will show you the possibilities corresponding to what you typed. Hit the space bar (or any other key that isn't allowed in a variable, property, or method name, and it will fill in the rest for you. You can also summon IntelliSense with keyboard combinations, or use the Edit > IntelliSense menu to request particular assistance. The IntelliSense menu only shows when the cursor is in the code window, so if you can't find it, that's why! Those options are worth considering, so here's a list: Licensed under Creative Commons Attribution-NonCommercial-NoDerivs 2.0 license. http://creativecommons.org/licenses/by-nc-nd/2.0/

2 Using Visual Studio.NET: IntelliSense and Debugging List Members (Ctrl+J) The List Members option is what you get in the traditional "type a period and see the list" option. You can summon the list any time, though, and it will show you everything in scope at the cursor position. This means that you can type part of a variable name and find it in the list. Parameter Information (Ctrl+Shift+Space) Parameter information is automatically displayed when you type the open parenthesis of a method call, but you may want to see the full list of parameters when you've clicked into an existing method call. This will show you the list, provided that you're in a method call. (If you're not, it does nothing.) Quick Info (Ctrl+K, then Ctrl+I) If there's documentation available for the identifier the cursor is in when you choose this, Visual Studio.NET will show it as a tooltop. At minimum, you'll at least get its declaration. Complete Word (Alt+Right Arrow, or Ctrl+Space) If you've typed enough of a word for IntelliSense to guess how to finish it, this will complete the word for you. If you haven't, you'll get a list like that provided by List Members, which will be set at the closest point IntelliSense can guess. All of this sounds pretty good, and is generally helpful, but there's one catch: Visual Studio.NET's IntelliSense isn't always perfect when it comes to the.net Compact Framework. It's not precisely a problem with IntelliSense, but rather a design issue in the.net Compact Framework: some methods are implemented by various controls, but are implemented so that they do nothing. IntelliSense can tell that the method is there, but not that it's empty. If you find yourself facing mysterious behavior when IntelliSense insists a method exists, this is the likely problem. Debugging The other major feature which Visual Studio.NET provides is a debugging environment that will let you set breakpoints and inspect values in running code. You can perform debugging on both the emulator and actual devices. We'll start with the emulator, and then discuss how this works (pretty much the same, just slower) on actual devices. Emulator testing is fine for basic applications, but if you need to do anything with I/O, you'll definitely want to test on an actual device. To get started, we'll return to the very simple application from the previous chapter which asked the user to enter some information into a text field and then changed values or showed a message box depending on what button they pushed. A simple breakpoint is the right place to start. You can add a breakpoint to any line in your program by putting the cursor in it and pressing F9. To remove it, just press F9 again - it toggles the breakpoint on and off. Figure 2-1 shows the code window for the MySecondFormVB project created in the previous chapter, with a breakpoint added on the line which displays a message box. 2

Debugging 3 of 5 Figure 2-1. Code window, with a breakpoint added. If you then run the program, using the F5 key (which starts it with debugging), everything will run normally until you click the "Display As Message" button. When you do that, the Visual Studio.NET window will reappear, looking like Figure 2-2. Figure 2-2. Visual Studio.NET responding to a breakpoint. Visual Studio.NET both highlights the code where the breakpoint occurred and shows some key information at the bottom of the screen. The Autos area lists variables in use in the current call (and its neighbors), their value, and their type. Since the MsgBox routine is using UserInput.Text as part of its text, that name, value, and type all appear. If you click on the Locals tab, you'll see a similar window listing variables currently in scope. You can change the values of these variables as well as watch them go by. If you change 3

4 Using Visual Studio.NET: IntelliSense and Debugging a variable, its new value will appear in red. For fun, I changed the value to "This will hit breakpoint." On the lower right, you'll also see the call stack - which methods or functions were called that brought us here. In this case, we can see that AsMessage_Click was called, then there were a few layers of non-user code, and then the whole thing was started by the Main routine. (As was discussed in the previous chapter, there is no explicit Main routine in Visual Basic.NET, just a property setting that identifies the base form.) If you want to explore the non-user code, right-click on the call stack and choose "Show Non-User Code". You can also click on the Breakpoints tab to see currently set breakpoints, or the Command Window tab to be a super-expert and type in Visual Studio.NET commands directly. Now that the program is stopped, you can control its execution line by line. F11 is "Step Into", which executes the current line and shifts the breakpoint to any functions or subroutines being called so you can watch their internal processing. If you're not interested in those details, F10, "Step Over", executes the current line and goes to the next, letting whatever function calls happen without investigating their contents. If you step into a function and decide that you're not interested in its internal details, you can use Shift+F11 to "Step Out" of the current function. All of these are also available from the Debug menu. For starters, we'll hit F10, which will let the MsgBox command do its thing with the modified variable. As Figure 2-3 shows, the UserInput.Text property changed, and we have a message box showing a slightly broken message. Figure 2-3. The emulator proceeding, with the contents of the message modified from Visual Studio.NET. 4

Debugging 5 of 5 When you click the ok button on the message box to make it go away, you'll be returned to the debugger, which will now be highlighting the End Sub line, as shown in Figure 2-4. (The MsgBox line will still be maroon.) Figure 2-4. Stepping to the next line in the debugger. The Pocket PC emulator will still be displaying the message box until we get out of this subroutine and the form can redraw itself. To let it do that, you can either single-step again, or you can press F5. Once you're debugging, F5 becomes Continue rather than Start. If you want to halt the program, you can press Shift-F5 instead and go back to editing the code to fix whatever dire problems you've discovered. Once you've continued, the program will go on running until it hits another breakpoint. In this case, there's only one breakpoint, set explicitly at that line. You can solve a lot of difficult programming problems using just the techniques shown above, but there's one more feature you should know about: setting breakpoints based on rules. This chapter is licensed under the Creative Commons Attribution- NonCommercial-NoDerivs 2.0 license. (http://creativecommons.org/licenses/bync-nd/2.0/) 5