Manuals
/
Microsoft
/
Computer Equipment
/
Computer Accessories
Microsoft
9GD00001
manual
Models:
9GD00001
1
1
449
449
Download
449 pages
12.58 Kb
1
2
3
4
5
6
7
8
Install
A database diagram
Default Namespace
Symbols
Administrative Tools window
Configuring Debug Mode
Resetting All Settings
Setup Welcome window
IDTCommandTarget Interface
Assembly Information
Page 1
Image 1
Page 1
Page 2
Page 1
Image 1
Page 1
Page 2
Contents
Page
Microsoft Visual Studio
About the Technical Editor
About the Author
Joe Mayo
Terms of USE
To my son, Kamo
This page intentionally left blank
Contents at a Glance
Viii Microsoft Visual Studio 2010 a Beginner’s Guide
Contents
Learning Just Enough C# and VB.NET Types and Members
Contents
Xii
Xiii
Xiv
Part V Appendixes
This page intentionally left blank
Xvii
Acknowledgments
This page intentionally left blank
Xix
Introduction
Xx Microsoft Visual Studio 2010 a Beginner’s Guide
Introduction
This page intentionally left blank
Part
This page intentionally left blank
Chapter
Key Skills & Concepts
What Is Visual Studio 2010 About?
Automatically Generated Code
Everything at Your Fingertips
Rapid Coding Experience
Customizability and Extensibility
Microsoft Visual Studio 2010 Setup window
Installing Visual Studio
Setup Welcome window
Setup Licensing window
Setup Customization window
Setup Progress window
Setup Success window
Checking for service releases
Navigating the Visual Studio 2010 Environment
10 Visual Studio 2010 Start screen
Menu
Work Area
Toolbar
Managing VS Windows
Solution Explorer
Toolbox
Status Bar
11 Window title bar icons
Expanding and Collapsing Windows
13 Pinned Toolbox
Docking Windows
14 Dragging a window for docking
Floating Windows
15 Floating a window
Tabbed Windows
16 Tabbed document windows
Closing and Opening Windows
17 Import and Export Settings Wizard
Modifying Environment Settings after Setup
18 Choose Settings To Export window
Exporting Selected Environment Settings
19 Name Your Settings File window
Importing Selected Environment Settings
20 Export Complete window
21 Save Current Settings window
22 Choose a Collection Of Settings To Import window
23 Choose Settings To Import window
Resetting All Settings
24 Import Complete window
Familiarization with Visual Studio Project Types
25 Default Collection Of Settings window
26 Reset Complete window
27 Selecting a New Project via the File menu
Windows Projects
28 New Project window
Web Projects
Office Projects
Summary
SharePoint Projects
Database Projects
Learning Just Enough C# or VB.NET Basic Syntax
Starting a Bare-Bones Project
Learning Just Enough C# or VB.NET Basic Syntax
A Console application in the Solution Explorer
Listing 2-1 Console application skeleton code
Examining the Code Skeleton
Main Method
Program Class
FirstProgram Namespace
VS Code editor
An Overview of the VS Code Editor
Bookmarks
Class and Member Locators
Bookmark Shortcut Keys
Bookmarks window
Setting Editor Options
Options window
Saving Time with Snippets
Using snippets
Filling in the Snippet template
Making Intellisense Work for You
Coding Expressions and Statements
Microsoft Visual Studio 2010 a Beginner’s Guide
10 Intellisense options
Running Programs
Primitive Types
Primitive Types and Expressions
Primitive Types
NET
Expressions
Ternary and Immediate If Operators
Enums
Listing 2-2 a ternary operator example
Listing 2-3 An example of an enum
Listing 2-4 Using an enum
Branching Statements
11 The C# if statement snippet template
If and else Snippets
Switch/Select Statements
13 a switch snippet template
Switch Statement Snippets
For Loops
Loops
For Each Loops
For Loop Snippet
17 The C# for each loop snippet template
For Each Loop Snippet
While Loop Snippet
While Loops
Do Loop Snippet
Do Loops
22 The VB do loop while snippet template
Learning Just Enough # and VB.NET Types and Members
Class Syntax
Creating Classes
Listing 3-1 a new Employee class
Listing 3-2 Code that uses a class
Learning Just Enough C# and VB.NET Types and Members
Listing 3-3 Class inheritance
Class Inheritance
Class Snippet
Listing 3-4 Code using inheritance
Writing Methods
Declaring and Using a Method
Listing 3-5 Declaring and calling a method
# MessagePrinter.cs
Program.PrintMessageStatic MessagePrinter.PrintMessageShared
Listing 3-6 Declaring a method that takes parameters
Declaring Parameters and Passing Arguments
# MessagePrinter.cs
VB MessagePrinter.vb
Listing 3-7 Returning values from methods
Returning Data and Using Method Results
# Calc.cs
VB sub snippet template
Method Snippets
Listing 3-8 Using fields and properties
Declaring and Using Fields
Coding Fields and Properties
Microsoft Visual Studio 2010 a Beginner’s Guide
Declaring and Using Properties
Microsoft Visual Studio 2010 a Beginner’s Guide
Listing 3-9 Property that wraps object state with no logic
Listing 3-10 Auto-implemented properties
Property Snippet
Summary
This page intentionally left blank
Learning Just Enough # and VB.NET Intermediate Syntax
Understanding Delegates and Events
Listing 4-1 Event demo
Events
Microsoft Visual Studio 2010 a Beginner’s Guide
Learning Just Enough C# and VB.NET Intermediate Syntax
Delegates
Code completion for delegate assignment
Event, Delegate, and Handler Code Completion
Code completion for handler method creation
Implementing Interfaces
Listing 4-2 An interface
Creating an Interface
Making Classes Implement the Interface
Listing 4-4 Saving class that implements IAccount interface
Microsoft Visual Studio 2010 a Beginner’s Guide
101
Writing Code That Uses an Interface
Microsoft Visual Studio 2010 a Beginner’s Guide
103
Microsoft Visual Studio 2010 a Beginner’s Guide
105
C# interface snippet template
Interface Snippet
Applying Arrays and Generics
Listing 4-7 Creating and using an array
Coding Arrays
107
Microsoft Visual Studio 2010 a Beginner’s Guide
109
Coding Generics
Listing 4-8 Coding a generic list collection
Summary
Learning the VS 2010 Environment
This page intentionally left blank
113
Creating and Building Projects
Constructing Solutions and Projects
115
Creating a New Project
Navigating the Solution Explorer
117
Solution Explorer window
Project Properties window
Examining Property Settings
Default Namespace
Assembly Name
Target Framework
Output Type
Icon and Manifest
Startup Object
121
Assembly Information
File Properties window
Referencing Assemblies
123
Adding a .NET Assembly Reference
Managing Assembly References
125
Referencing Your Own Class Libraries
Using Code in Class Libraries
Listing 5-1 Class library code
127
Listing 5-2 Application code calling class library code
Compiling Applications
Building Solutions/Projects
129
Cleaning Solutions/Projects
Rebuilding Solutions/Projects
131
Managing Dependencies and Build Order
Project Dependencies window
133
Managing Compilation Settings
Microsoft Visual Studio 2010 a Beginner’s Guide
11 The VB Compile Options
135
12 The Class View window
Navigating a Project with Class View
Class Designer Visualization
Using the Class Designer
137
14 Generating code with the Class Designer
Class Designer Code Generation
15 Adding a new object to the Class Designer
139
Listing 5-3 Code generated from the Class Designer
141
This page intentionally left blank
143
Debugging with Visual Studio
Example Code for This Chapter
Listing 6-1 Example code for chapter
145
VB Module1.vb
VB Customer.vb
147
Development-Time Code Tools
Call Hierarchy window
149
Configuring Debug Mode
Build C# and Compile VB Properties tab
151
Debug Output folder
Debug properties
153
TIP
155
Setting Breakpoints
A breakpoint
Creating a Breakpoint
157
Customizing a Breakpoint
Options from the Breakpoint Context Menu
Managing Breakpoints
Stepping Through Code
Step Operations
159
Locals and Autos Windows
Inspecting Application State
161
Watch Windows
11 The Immediate window
Immediate Window
Quick Watch Window
Call Stack Window
163
13 The Quick Watch window
Watching Variables with Pin To Source
165
Working with IntelliTrace
15 The Debug History window
Solving Problems with VS Debugger
167
Program with Bugs
Customer Class
CustomerRepository Class
Program with Bugs
169
Microsoft Visual Studio 2010 a Beginner’s Guide
171
Finding the Bug
Cust.FirstName == Jean Cust.FirstName = Jean
16 The Memory window
173
Fixing the First Bug
175
Debugging and Resolving NullReferenceException Problems
Microsoft Visual Studio 2010 a Beginner’s Guide
Customers.IndexOfcust ?customers.IndexOfcust
177
Microsoft Visual Studio 2010 a Beginner’s Guide
179
Summary
181
Working with Data
Introduction to Server Explorer
Working with Databases
183
Creating a Database
Create New SQL Server Database
185
Adding Tables
Adding data to a table
187
Relating Tables with Foreign Keys
Managing a foreign key relationship
189
Configuring a foreign key relationship
Foreign key relationship Save warning message
191
A database diagram
Listing 7-1 Stored procedure example
Adding Stored Procedures
193
Configuring Database Options
Querying Object Collections with Linq
Learning Language Integrated Query Linq
195
Microsoft Visual Studio 2010 a Beginner’s Guide
197
Creating a Linq Projection with Anonymous Types
199
Using Linq to Sort Collection Results
Handling Data with Linq to SQL
Setting Up Linq to SQL
201
Working with the Linq to SQL Designer
12 The Linq to SQL Class Designer Properties window
203
Introduction to Querying Linq to SQL
Listing 7-3 Querying data with Linq to SQL
Here’s the output using my data
205
Performing Queries on Multiple Tables
Here’s the output
207
Microsoft Visual Studio 2010 a Beginner’s Guide
Output is
209
Inserting Data with Linq to SQL
211
Updating Data with Linq to SQL
Deleting Data with Linq to SQL
213
Summary
Building Programs with VS
This page intentionally left blank
217
Building Desktop Applications with WPF
Perform Screen Layout Use Controls Work with Data in the UI
Starting a WPF Project
A new WPF application project
219
Grid Layout
Understanding Layout
Adding columns and rows to a Grid
221
Column and row sizing options
StackPanel Layout
223
DockPanel Layout
DockPanel layout
WrapPanel Layout
225
Canvas Layout
Managing Windows for Controls
Using WPF Controls
Primary Windows for Working with Controls
227
Handling Events
Setting Properties
Listing 8-1 a WPF code-behind file
229
Private void button1Clickobject sender, RoutedEventArgs e
231
10 Readable button ID and event handler name
233
Coding Event Handlers
Working with Data in WPF
235
Setting Up a Data Source
11 Choosing a new data source
12 Selecting data objects
237
14 Changing the control type for a field
15 Controls bound via a data source
239
Microsoft Visual Studio 2010 a Beginner’s Guide
241
Configuring a ComboBox
ComboBox Properties for Data Binding
Property Explanation
243
Reading and Saving Data
Using the DataGrid
16 Displaying information in a Grid
245
Microsoft Visual Studio 2010 a Beginner’s Guide
247
This page intentionally left blank
249
ASP.NET MVC
Purpose of MVC Objects
Understanding ASP.NET MVC
251
Starting an ASP.NET MVC Project
A new ASP.NET MVC project
253
Running the default code produced by an ASP.NET MVC project
Building Controllers
Creating the Models
Listing 9-1 The HomeController class
255
Looking Inside a View
Displaying Views
Listing 9-2 a View’s Html
257
Assigning MasterPage Files
Organizing View Files
Listing 9-3 a MasterPage
259
Partial Views a.k.a. User Controls
261
Listing 9-4 Contents of a Partial View
Managing Routing
Listing 9-5 Setting up routing
263
Building a Customer Management Application
265
Creating a Repository
Listing 9-6 a repository for working with customer data
Microsoft Visual Studio 2010 a Beginner’s Guide
267
Creating a new Controller
Creating a Customer Controller
269
Displaying a Customer List
Listing 9-7 a Controller for displaying a list
Add View window
Listing 9-8 a Customer List View
271
Microsoft Visual Studio 2010 a Beginner’s Guide
Showing a list of objects
273
Listing 9-9 Creating a new Customer object
Adding a New Customer
275
Adding a new Customer
Listing 9-10 View for creating a new Customer
277
Microsoft Visual Studio 2010 a Beginner’s Guide
279
Updating Existing Customers
Listing 9-11 Methods for editing Customers
Microsoft Visual Studio 2010 a Beginner’s Guide
281
Deleting a Customer
Listing 9-12 The Delete Controller method
Listing 9-13 Deleting a Customer
283
Summary
285
Designing Silverlight Applications
Starting a Silverlight Project
Creating a new Silverlight application
287
Listing 10-1 Hosting a Silverlight application on a Web
Object Tag Parameters for Silverlight
289
Navigating the Silverlight Designer
Using Silverlight Controls
Playing Silverlight videos
291
Listing 10-2 Playing and stopping a video
Dim misPlaying As Boolean = False
293
Silverlight properties
Running Silverlight Out-of-Browser OOB
295
Out-of-browser settings
Choosing OOB
297
Deploying Silverlight Applications
Summary
299
Deploying Web Services with WCF
Key Skills & Concepts
301
Starting a WCF Project
Specifying a Contract with WCF Interfaces
Listing 11-1 a WCF service interface
Examining the VS-Generated Contract
303
Microsoft Visual Studio 2010 a Beginner’s Guide
Creating Your Own Contract
305
Listing 11-2 WCF service contract implementation
307
Listing 11-3 a custom type for a WCF service contract
Implementing Logic with WCF Classes
Listing 11-4 Default WCF service implementation class
309
Listing 11-5 a WCF service implementation
311
Microsoft Visual Studio 2010 a Beginner’s Guide
313
Hosting a WCF Service
Installing IIS 7 on Windows
Following General Hosting Procedures
315
Uninstall Or Change a Program window
317
Creating a Web Site on IIS 7 on Windows
Administrative Tools window
IIS Manager window
319
Add Web Site window
321
Deploying the WCF Service to IIS
Authentication And Authorization window
323
Listing 11-6 The WCF service address in app.config
Microsoft Visual Studio 2010 a Beginner’s Guide
325
10 The Publish WCF Service window
Creating a Service Reference
Communicating with a WCF Service
327
11 The Add Service Reference window
Microsoft Visual Studio 2010 a Beginner’s Guide
329
Coding Web Service Calls
Microsoft Visual Studio 2010 a Beginner’s Guide
331
Similarly, you can delete a Customer, as follows
333
13 The Service Reference Settings window
Listing 11-7 An application using a Web service
335
Configuration Files for Each Application Type
Deploying a Client That Consumes a Web Service
Listing 11-8 Web service client configuration
Creating a Web Service in a Web Site
337
Summary
Enhancing the VS 2010 Experience
This page intentionally left blank
341
Customizing Development Environment
Implementing Custom Templates
343
Creating New Project Templates
Modifying a Project
Choose Template Type window
Exporting the Project Template
Select Template Options window
345
Using the New Project Template
347
Creating New Item Templates
Creating an Item Template
Add the following code to the file C#
Exporting the Item Template
349
Select Item To Export window
351
Using an Item Template
Select Template Options window
Creating a New Snippet
Creating Custom Snippets
353
Listing 12-1 Inside the for snippet
Examining Existing Snippets
355
Creating New Snippets
Listing 12-2 a custom method snippet
357
File Folders Holding Snippets
Managing the Snippet Library
359
Using the Snippets Manager
Recording a Macro
Writing Macros
361
Parameter name
363
Saving a Macro
365
Editing Macros
Microsoft Visual Studio 2010 a Beginner’s Guide
367
Microsoft Visual Studio 2010 a Beginner’s Guide
369
VB doesn’t have problem that occurs in C# code
DTE.Windows.ItemCustomer.cs.Activate
371
Extending Visual Studio
Running the Add-In Project Wizard
Creating a Visual Studio Add-In
Selecting a Visual Studio Add-In in the New Project window
373
Select a Programming Language window
Enter a Name And Description window
375
Choosing ‘Help About’ window
377
Examining an Add-In Wizard Solution
Drilling into the Connect Class
379
IDTCommandTarget Interface
IDTExtensibility2 Interface
Listing 13-1 Skeleton code for the Connect class
381
Microsoft Visual Studio 2010 a Beginner’s Guide
383
Adding Functionality to an Add-In
Understanding OnConnection Parameters
Reviewing the OnConnection Method
OnConnection Method Parameters
Reviewing OnConnection Generated Code
385
Listing 13-2 The OnConnection method
Microsoft Visual Studio 2010 a Beginner’s Guide
387
Microsoft Visual Studio 2010 a Beginner’s Guide
389
Microsoft Visual Studio 2010 a Beginner’s Guide
391
Implementing the Exec Method
Listing 13-3 Implementing the Exec method
Microsoft Visual Studio 2010 a Beginner’s Guide
393
Microsoft Visual Studio 2010 a Beginner’s Guide
395
Setting Status with QueryStatus
Listing 13-4 The QueryStatus method
Microsoft Visual Studio 2010 a Beginner’s Guide
397
Deploying an Add-In
Listing 13-5 Contents of the *.AddIn file
399
Where to Go Next
Joe Mayo
Appendixes
This page intentionally left blank
403
Appendix a
XML Prefixes
VS 2010 XML Editor
Listing A-1 An XML document example
Attributes
XML Elements
405
Listing A-2 XML namespace example
Namespaces
XML Menu
Configuring XML Options
407
This page intentionally left blank
409
Appendix B
Listing B-1 a new Xaml file
Attributes as Properties
Elements as Classes
Executing the Xaml Document
411
Property Elements
Listing B-2 a Button with Content set as an attribute
413
Figure B-2 a Button with its Content attribute set as Text
Markup Extensions
Figure B-3 Button with Content property element set to Image
415
Listing B-3 Markup extension for using resources
Summary
417
Symbols
Microsoft Visual Studio 2010 a Beginner’s Guide
Index
Microsoft Visual Studio 2010 a Beginner’s Guide
Index
Methods, 72-80.See also specific methods
Vs. fields, 83 Properties folder, 117
Microsoft Visual Studio 2010 a Beginner’s Guide
Index
Microsoft Visual Studio 2010 a Beginner’s Guide
Top
Page
Image
Contents