1756 Professional Visual Studio 2012
www.it-ebooks.info
www.it-ebooks.info
PROFESSIONAL VISUAL STUDIO® 2012
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxix
⊲ PART I
INTEGRATED DEVELOPMENT ENVIRONMENT
CHAPTER 1
A Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 2
The Solution Explorer, Toolbox, and Properties . . . . . . . . . . . . . . . . . . . . .13
CHAPTER 3
Options and Customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
CHAPTER 4
The Visual Studio Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
CHAPTER 5
Find and Replace and Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
⊲ PART II
GETTING STARTED
CHAPTER 6
Solutions, Projects, and Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
CHAPTER 7
IntelliSense and Bookmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
CHAPTER 8
Code Snippets and Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
CHAPTER 9
Server Explorer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
CHAPTER 10
Modeling with the Class Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
⊲ PART III
DIGGING DEEPER
CHAPTER 11
Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
CHAPTER 12
Documentation with XML Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
CHAPTER 13
Code Consistency Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
CHAPTER 14
Code Generation with T4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
CHAPTER 15
Project and Item Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
CHAPTER 16
Language-Specific Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
⊲ PART IV RICH CLIENT APPLICATIONS
CHAPTER 17
Windows Forms Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
CHAPTER 18
Windows Presentation Foundation (WPF) . . . . . . . . . . . . . . . . . . . . . . . . 305
CHAPTER 19
Office Business Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
CHAPTER 20
Windows Store Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Continues
www.it-ebooks.info
⊲ PART V
WEB APPLICATIONS
CHAPTER 21
ASP.NET Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
CHAPTER 22
ASP.NET MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
CHAPTER 23
Silverlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 24
Dynamic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
CHAPTER 25
SharePoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
CHAPTER 26
Windows Azure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
⊲ PART VI DATA
CHAPTER 27
Visual Database Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
CHAPTER 28
DataSets and DataBinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
CHAPTER 29
Language Integrated Queries (LINQ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
CHAPTER 30
The ADO.NET Entity Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
CHAPTER 31
Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
⊲ PART VII APPLICATION SERVICES
CHAPTER 32
Windows Communication Foundation (WCF) . . . . . . . . . . . . . . . . . . . . . 619
CHAPTER 33
Windows Workflow Foundation (WF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
CHAPTER 34
Client Application Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
CHAPTER 35
Synchronization Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
CHAPTER 36
WCF RIA Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
⊲ PART VIII CONFIGURATION AND RESOURCES
CHAPTER 37
Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
CHAPTER 38
Connection Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
CHAPTER 39
Resource Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
⊲ PART IX DEBUGGING
CHAPTER 40
Using the Debugging Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .751
CHAPTER 41
Debugging with Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 769
CHAPTER 42
DataTips, Debug Proxies, and Visualizers . . . . . . . . . . . . . . . . . . . . . . . . 781
CHAPTER 43
Debugging Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
CHAPTER 44
Advanced Debugging Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
www.it-ebooks.info
⊲ PART X
BUILD AND DEPLOYMENT
CHAPTER 45
Upgrading with Visual Studio 2012. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
CHAPTER 46
Build Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
CHAPTER 47
Assembly Versioning and Signing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
CHAPTER 48
Obfuscation, Application Monitoring, and Management . . . . . . . . . . . 861
CHAPTER 49
Packaging and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
CHAPTER 50
Web Application Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
⊲ PART XI CUSTOMIZING AND EXTENDING VISUAL STUDIO
CHAPTER 51
The Automation Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .909
CHAPTER 52
Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
CHAPTER 53
Managed Extensibility Framework (MEF) . . . . . . . . . . . . . . . . . . . . . . . . 931
⊲ PART XII VISUAL STUDIO ULTIMATE
CHAPTER 54
Visual Studio Ultimate for Architects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 953
CHAPTER 55
Visual Studio Ultimate for Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . 965
CHAPTER 56
Visual Studio Ultimate for Testers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983
CHAPTER 57
Team Foundation Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1021
www.it-ebooks.info
www.it-ebooks.info
PROFESSIONAL
Visual Studio® 2012
Bruce Johnson
www.it-ebooks.info
Professional Visual Studio® 2012
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-33770-7
ISBN: 978-1-118-41648-8 (ebk)
ISBN: 978-1-118-43407-9 (ebk)
ISBN: 978-1-118-46390-1 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201)
748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold
with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services.
If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to
in this work as a citation and/or a potential source of further information does not mean that the author or the publisher
endorses the information the organization or Web site may provide or recommendations it may make. Further, readers
should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was
written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such
as a CD or DVD that is not included in the version you purchased, you may download this material at
http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2012944689
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may not be used without written permission. Visual Studio is a registered trademark of Microsoft Corporation.
All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any
product or vendor mentioned in this book.
www.it-ebooks.info
I’d like to thank my wife, Ali, and my four children,
Kyle, Cameron, Gillian, and Curtis, for their love
and support. While they might not have written any
of the words directly, they certainly helped create an
environment where I could get my ideas out my head
and into the computer.
— Bruce Johnson
www.it-ebooks.info
CREDITS
ACQUISITIONS EDITOR
PRODUCTION MANAGER
Mary James
Tim Tate
PROJECT EDITOR
VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER
Kelly Talbot
Richard Swadley
TECHNICAL EDITORS
Joe Bennett
Andrew Moore
VICE PRESIDENT AND EXECUTIVE PUBLISHER
PRODUCTION EDITOR
ASSOCIATE PUBLISHER
Christine Mugnolo
Jim Minatel
COPY EDITOR
PROJECT COORDINATOR, COVER
San Dee Phillips
Katie Crocker
EDITORIAL MANAGER
PROOFREADERS
Mary Beth Wakefield
Jennifer Bennett, Word One New York
Scott Klemp, Word One New York
James Saturnio, Word One New York
Neil Edde
FREELANCER EDITORIAL MANAGER
Rosemarie Graham
INDEXER
ASSOCIATE DIRECTOR OF MARKETING
Johnna VanHoose Dinse
David Mayhew
COVER DESIGNER
MARKETING MANAGER
LeAndra Young
Ashley Zurcher
COVER IMAGE
BUSINESS MANAGER
© Eric Delmar / iStockPhoto
Amy Knies
www.it-ebooks.info
ABOUT THE AUTHOR
BRUCE JOHNSON is a partner at ObjectSharp Consulting and a 30-year veteran of the computer industry.
The fi rst third of his career was spent doing “real work,” otherwise known as coding in the UNIX world.
But for almost 20 years, he has been working on projects that are at the leading edge of Windows technology, from C++ through Visual Basic to C#, and from thick client applications to websites to services.
As well as having fun with building systems, Bruce has spoken hundreds of times at conferences
and user groups throughout North America. He has been a Microsoft Certified Trainer (MCT)
for the past three years and he is a co-president of the Metro Toronto .NET User Group. He has also
written columns and articles for numerous magazines. While the quantity of the posts on his blog
(http://blogs.objectsharp.com/author/bruce.aspx) has decreased recently, the activity on his
Twitter account (http://www.twitter.com/lacanuck) has shown a corresponding increase. For all of this
activity (or, perhaps, in spite of it), Bruce has been privileged to be recognized as a Microsoft MVP
for the past six years.
www.it-ebooks.info
www.it-ebooks.info
ACKNOWLEDGMENTS
TO THE OUTSIDE, it might look like the writing of a book is an individual effort. Having gone through this
act of creation a number of times, I can tell you that nothing is further from the truth. Yes, there is a lot of
effort on the part of the author (and the feeling of joy you get as you hand in your last rewrite is quite palpable). But I can also tell you that without the rarely acknowledged efforts of the others involved in the editorial process, the book would never have made it to completion. And if you, as the reader, take something
useful from this book, odds are that my editor, my technical reviewer, and the project editor are the reason
why.
I would especially like to thank everyone at Wrox who has helped me through this process. In particular,
thanks go out to Kelly Talbot, whose patience and attention to detail are quite impressive. Thanks also go to
Andrew Moore and Joe Bennett, who did a great job making sure that the technical details of the book were
accurate. Finally, thanks to San Dee Phillips, who had the unenviable chore of ensuring that I wasn’t writing in the passive voice and fi xed it when I stopped writing so well. The efforts of all of these individuals are
what make the book possible and, hopefully, a success. Thanks also to Mary James, who was kind enough
to take a chance on my ability to write.
Lastly, I would like to thank all of my associates at ObjectSharp and the people at Microsoft who, although
they might not have realized it, were keeping the writing process going by answering any questions I had.
— Bruce Johnson
www.it-ebooks.info
www.it-ebooks.info
CONTENTS
INTRODUCTION
xxxix
PART I: INTEGRATED DEVELOPMENT ENVIRONMENT
CHAPTER 1: A QUICK TOUR
3
Getting Started
3
Installing Visual Studio 2012
Running Visual Studio 2012
3
4
The Visual Studio IDE
5
Developing, Building, Debugging, and Deploying
Your First Application
Summary
7
12
CHAPTER 2: THE SOLUTION EXPLORER, TOOLBOX, AND PROPERTIES 13
The Solution Explorer
13
Previewing Files
Common Tasks
15
16
The Toolbox
21
Arranging Components
Adding Components
23
24
Properties
25
Extending the Properties Window
Summary
27
30
CHAPTER 3: OPTIONS AND CUSTOMIZATIONS
The Start Page
31
31
Customizing the Start Page
32
Window Layout
32
Viewing Windows and Toolbars
Navigating Open Items
Docking
The Editor Space
33
33
34
37
Fonts and Colors
Visual Guides
Full-Screen Mode
Tracking Changes
38
38
40
40
www.it-ebooks.info
CONTENTS
Other Options
41
Keyboard Shortcuts
Quick Launch
Projects and Solutions
Build and Run
VB Options
41
42
43
44
45
Importing and Exporting Settings
Summary
CHAPTER 4: THE VISUAL STUDIO WORKSPACE
The Code Editor
45
47
49
49
The Code Editor Window Layout
Regions
Outlining
Code Formatting
Navigating Forward/Backward
Additional Code Editor Features
Split View
Tear Away (Floating) Code Windows
Duplicating Solution Explorer
Creating Tab Groups
Advanced Functionality
49
50
51
51
53
53
53
54
55
56
56
The Command Window
The Immediate Window
The Class View
The Error List
The Object Browser
The Code Definition Window
The Call Hierarchy Window
The Document Outline Tool Window
58
59
59
60
61
61
62
63
HTML Outlining
Control Outlining
63
64
Reorganizing Tool Windows
Summary
CHAPTER 5: FIND AND REPLACE AND HELP
Quick Find/Replace
66
66
67
67
Quick Find
Quick Replace
Find Options
68
69
69
xiv
www.it-ebooks.info
CONTENTS
Find and Replace Options
70
Find/Replace in Files
70
Find in Files
Find Dialog Options
Regular Expressions
Results Window
Replace in Files
70
71
72
73
74
Navigate To
Accessing Help
74
75
Navigating and Searching the Help System
Configuring the Help System
Summary
76
77
77
PART II: GETTING STARTED
CHAPTER 6: SOLUTIONS, PROJECTS, AND ITEMS
Solution Structure
Solution File Format
Solution Properties
81
81
83
83
Common Properties
Configuration Properties
84
85
Project Types
Project Files Format
Project Properties
86
88
88
Application
Compile (Visual Basic Only)
Build (C# and F# Only)
Build Events (C# and F# Only)
Debug
References (Visual Basic Only)
Resources
Services
Settings
Reference Paths (C# and F# Only)
Signing
My Extensions (Visual Basic Only)
Security
Publish
Code Analysis
89
92
93
94
94
96
97
97
98
99
100
100
101
102
102
xv
www.it-ebooks.info
CONTENTS
Web Application Project Properties
Web
Silverlight Applications
Package/Publish Web
Package/Publish SQL
103
103
104
105
106
Web Site Projects
Summary
107
107
CHAPTER 7: INTELLISENSE AND BOOKMARKS
IntelliSense Explained
109
109
General IntelliSense
IntelliSense and C++
Completing Words and Phrases
Parameter Information
Quick Info
JavaScript IntelliSense
110
111
111
116
117
117
The JavaScript IntelliSense Context
Referencing Another JavaScript File
IntelliSense Options
118
118
119
General Options
Statement Completion
C#-Specific Options
119
121
121
Extended IntelliSense
122
Code Snippets
XML Comments
Adding Your Own IntelliSense
Bookmarks and the Bookmark Window
Summary
CHAPTER 8: CODE SNIPPETS AND REFACTORING
Code Snippets Revealed
122
123
123
123
125
127
128
Storing Code Blocks in the Toolbox
Code Snippets
Using Snippets in C#
Using Snippets in VB
Surround With Snippet
Code Snippets Manager
Creating Snippets
Reviewing Existing Snippets
Accessing Refactoring Support
xvi
www.it-ebooks.info
128
129
129
130
131
132
133
133
136
CONTENTS
Refactoring Actions
137
Extract Method
Encapsulate Field
Extract Interface
Reorder Parameters
Remove Parameters
Rename
Generate Method Stub
Organize Usings
137
140
140
143
143
144
145
145
Summary
146
CHAPTER 9: SERVER EXPLORER
Server Connections
147
147
Event Logs
Management Classes
Management Events
Message Queues
Performance Counters
Services
148
150
152
154
156
159
Data Connections
SharePoint Connections
Summary
160
160
161
CHAPTER 10: MODELING WITH THE CLASS DESIGNER
Creating a Class Diagram
The Design Surface
The Toolbox
163
163
164
165
Entities
Connectors
165
166
The Class Details
The Properties Window
Layout
Exporting Diagrams
Code Generation and Refactoring
Drag-and-Drop Code Generation
IntelliSense Code Generation
Refactoring with the Class Designer
Modeling Power Toys for Visual Studio
Visualization Enhancements
Functionality Enhancements
166
167
168
168
169
169
171
171
172
172
173
Summary
174
xvii
www.it-ebooks.info
CONTENTS
PART III: DIGGING DEEPER
CHAPTER 11: UNIT TESTING
Your First Test Case
177
177
Identifying Tests Using Attributes
Additional Test Attributes
Asserting the Facts
183
183
185
The Assert Class
The StringAssert Class
The CollectionAssert Class
The ExpectedException Attribute
Initializing and Cleaning Up
TestInitialize and TestCleanup
ClassInitialize and ClassCleanup
AssemblyInitialize and AssemblyCleanup
Testing Context
185
186
186
186
188
188
188
188
189
Data
Writing Test Output
189
191
Advanced Unit Testing
192
Custom Properties
Testing Private Members
192
193
Testing Code Contracts
Summary
194
196
CHAPTER 12: DOCUMENTATION WITH XML COMMENTS
Inline Commenting
XML Comments
197
197
198
Adding XML Comments
XML Comment Tags
198
199
Using XML Comments
211
IntelliSense Information
212
Generating Documentation with GhostDoc
Compiling Documentation with Sandcastle
Task List Comments
Summary
CHAPTER 13: CODE CONSISTENCY TOOLS
Source Control
212
214
216
218
219
219
Selecting a Source Control Repository
Accessing Source Control
xviii
www.it-ebooks.info
220
222
CONTENTS
Coding Standards
226
Code Analysis with FxCop
Style Using StyleCop
Code Contracts
226
229
230
Summary
232
CHAPTER 14: CODE GENERATION WITH T4
233
Creating a T4 Template
T4 Building Blocks
233
236
Expression Blocks
Statement Blocks
Class Feature Blocks
237
237
239
How T4 Works
T4 Directives
240
242
Template Directive
Output Directive
Assembly Directive
Import Directive
Include Directive
242
243
243
243
244
Troubleshooting
245
Design-Time Errors
Compiling Transformation Errors
Executing Transformation Errors
Generated Code Errors
Generating Code Assets
Runtime Text Templates
245
245
246
246
246
250
Using Runtime Text Templates
251
Differences Between Runtime Text Templates and Standard T4 Templates 253
Tips and Tricks
Summary
254
255
CHAPTER 15: PROJECT AND ITEM TEMPLATES
Creating Templates
257
257
Item Template
Project Template
Template Structure
Template Parameters
Template Locations
257
261
262
263
265
Extending Templates
265
Template Project Setup
265
xix
www.it-ebooks.info
CONTENTS
IWizard
Generating the Extended Project Template
Starter Kits
Online Templates
Summary
266
271
272
273
273
CHAPTER 16: LANGUAGE-SPECIFIC FEATURES
Hitting a Nail with the Right Hammer
Imperative
Declarative
Dynamic
Functional
What’s It All Mean?
275
275
276
276
276
277
277
A Tale of Two Languages
278
The Async Keyword
Caller Information
278
280
Visual Basic
281
Iterators
The Global Keyword
Visual Basic PowerPacks
281
281
282
F#
283
Your First F# Program
Exploring F# Language Features
Type Providers
Query Expressions
Auto-Implemented Properties
Summary
283
285
287
287
288
288
PART IV: RICH CLIENT APPLICATIONS
CHAPTER 17: WINDOWS FORMS APPLICATIONS
Getting Started
The Windows Form
291
291
292
Appearance Properties
Layout Properties
Window Style Properties
293
293
293
Form Design Preferences
Adding and Positioning Controls
Vertically Aligning Text Controls
Automatic Positioning of Multiple Controls
xx
www.it-ebooks.info
294
296
297
297
CONTENTS
Tab Order and Layering Controls
Locking Control Design
Setting Control Properties
Service-Based Components
Smart Tag Tasks
Container Controls
298
299
299
300
301
301
Panel and SplitContainer
FlowLayoutPanel
TableLayoutPanel
301
302
303
Docking and Anchoring Controls
Summary
CHAPTER 18: WINDOWS PRESENTATION FOUNDATION (WPF)
303
304
305
What Is WPF?
Getting Started with WPF
305
307
XAML Fundamentals
The WPF Controls
The WPF Layout Controls
309
310
311
The WPF Designer and XAML Editor
Working with the XAML Editor
Working with the WPF Designer
The Properties Tool Window
Data Binding Features
Styling Your Application
Windows Forms Interoperability
Hosting a WPF Control in Windows Forms
Hosting a Windows Forms Control in WPF
Debugging with the WPF Visualizer
Summary
CHAPTER 19: OFFICE BUSINESS APPLICATIONS
Choosing an Office Project Type
Document-Level Customizations
Application-Level Add-ins
Creating a Document-Level Customization
Your First VSTO Project
Protecting the Document Design
Adding an Actions Pane
Creating an Application Add-in
Some Outlook Concepts
313
314
315
317
321
324
325
326
327
328
330
331
331
332
333
333
333
336
337
338
338
xxi
www.it-ebooks.info
CONTENTS
Creating an Outlook Form Region
Debugging Office Applications
Unregistering an Add-in
Disabled Add-ins
339
343
343
344
Deploying Office Applications
Summary
CHAPTER 20: WINDOWS STORE APPLICATIONS
What Is a Windows Store Application?
Content Before Chrome
Snap and Scale
Semantic Zoom
Contracts
Tiles
Embrace the Cloud
345
346
347
347
348
349
349
349
350
350
Creating a Windows Store Application
The Windows 8 Simulator
Your Windows Store Application
Summary
350
353
355
358
PART V: WEB APPLICATIONS
CHAPTER 21: ASP.NET WEB FORMS
Web Application Versus Web Site Projects
Creating Web Projects
Creating a Web Site Project
Creating a Web Application Project
Other Web Projects
Starter Kits, Community Projects, and Open-Source Applications
Designing Web Forms
361
362
362
363
366
367
368
368
The HTML Designer
Positioning Controls and HTML Elements
Formatting Controls and HTML Elements
CSS Tools
Validation Tools
Web Controls
368
370
372
372
376
377
Navigation Components
User Authentication
Data Components
Web Parts
377
378
379
382
xxii
www.it-ebooks.info
CONTENTS
Master Pages
Rich Client-Side Development
383
385
Developing with JavaScript
Working with ASP.NET AJAX
Using AJAX Control Extenders
385
386
388
ASP.NET Web Site Administration
390
Security
Application Settings
ASP.NET Configuration in IIS
391
393
393
Summary
394
CHAPTER 22: ASP.NET MVC
395
Model View Controller
Getting Started with ASP.NET MVC
Choosing a Model
Controllers and Action Methods
MVC Scaffolding
396
396
398
399
399
Rendering a UI with Views
Advanced MVC
402
409
Routing
Action Method Parameters
Areas
Validation
Partial Views
Dynamic Data Templates
jQuery
409
412
415
417
419
419
422
Summary
424
CHAPTER 23: SILVERLIGHT
425
What Is Silverlight?
Getting Started with Silverlight
Navigation Framework
Theming
Enabling Running Out of Browser
Summary
CHAPTER 24: DYNAMIC DATA
425
426
432
433
435
438
439
Creating a Dynamic Data Web Application
Adding a Data Model
Exploring a Dynamic Data Application
440
441
443
xxiii
www.it-ebooks.info
CONTENTS
Customizing the Data Model
Scaffolding Individual Tables
Customizing Individual Data Fields
Adding Custom Validation Rules
Customizing the Display Format
Customizing the Presentation
Page Templates
Field Templates
Entity Templates
Filter Templates
444
445
445
447
448
449
450
453
455
457
Enabling Dynamic Data for Existing Projects
Summary
CHAPTER 25: SHAREPOINT
Preparing the Development Environment
Installing the Prerequisites
Installing SharePoint 2010
Exploring SharePoint 2010
Creating a SharePoint Project
Building Custom SharePoint Components
Developing Web Parts
Creating Content Types and Lists
Adding Event Receivers
Creating SharePoint Workflows
460
460
461
462
462
464
465
467
471
471
472
475
476
Working with Features
Packaging and Deployment
Summary
478
480
481
CHAPTER 26: WINDOWS AZURE
483
The Windows Azure Platform
484
The Compute Emulator
Table, Blob, and Queue Storage
Application Deployment
SQL Azure
AppFabric
486
487
490
494
496
Service Bus
Access Control Service
496
496
Azure Websites
Azure Virtual Machines
496
497
Connectivity
497
Summary
498
xxiv
www.it-ebooks.info
CONTENTS
PART VI: DATA
CHAPTER 27: VISUAL DATABASE TOOLS
Database Windows in Visual Studio 2012
Server Explorer
The Data Sources Window
SQL Server Object Explorer
501
501
502
506
506
Editing Data
Summary
507
508
CHAPTER 28: DATASETS AND DATABINDING
DataSets Overview
509
509
Adding a Data Source
The DataSet Designer
510
511
Binding Data
514
BindingSource
BindingNavigator
Data Source Selections
Saving Changes
Inserting New Items
Validation
Customized DataSets
BindingSource Chains and the DataGridView
Working with Data Sources
516
518
519
521
523
524
525
527
529
The Web Service Data Source
Browsing Data
Summary
531
532
534
CHAPTER 29: LANGUAGE INTEGRATED QUERIES (LINQ)
535
LINQ Providers
Old-School Queries
Query Pieces
535
536
538
From
Select
Where
Group By
Custom Projections
Order By
538
539
539
540
541
541
Debugging and Execution
LINQ to XML
542
543
xxv
www.it-ebooks.info
CONTENTS
VB XML Literals
Creating XML with LINQ
544
544
Querying XML
Schema Support
LINQ to SQL
546
547
549
Creating the Object Model
Querying with LINQ to SQL
Binding LINQ to SQL Objects
LINQPad
Summary
549
551
556
558
559
CHAPTER 30: THE ADO.NET ENTITY FRAMEWORK
What Is the Entity Framework?
Comparison with LINQ to SQL
Entity Framework Concepts
Getting Started
Creating an Entity Model
561
562
562
562
563
563
The Entity Data Model Wizard
The Entity Framework Designer
Creating/Modifying Entities
Creating/Modifying Entity Associations
Entity Inheritance
Validating an Entity Model
Updating an Entity Model with Database Changes
Querying the Entity Model
LINQ to Entities Overview
Getting an Object Context
CRUD Operations
Navigating Entity Associations
Advanced Functionality
564
567
571
573
574
574
574
575
575
576
576
580
581
Updating a Database from an Entity Model
Adding Business Logic to Entities
Plain Old CLR Objects (POCO)
Summary
581
582
582
582
CHAPTER 31: REPORTING
583
Getting Started with Reporting
Designing Reports
Defining Data Sources
Reporting Controls
583
585
586
588
xxvi
www.it-ebooks.info
CONTENTS
Expressions, Placeholders, and Aggregates
Custom Code
Report Layout
Subreports
The Report Wizard
Rendering Reports
600
604
608
609
611
612
The Report Viewer Controls
Generating the Report
Rendering Reports to Different Formats
Deploying Reports
Summary
612
613
614
615
616
PART VII: APPLICATION SERVICES
CHAPTER 32: WINDOWS COMMUNICATION FOUNDATION (WCF)
What Is WCF?
Getting Started
Defining Contracts
619
619
620
621
Creating the Service Contract
Creating the Data Contract
Configuring WCF Service Endpoints
Hosting WCF Services
Consuming a WCF Service
Summary
CHAPTER 33: WINDOWS WORKFLOW FOUNDATION (WF)
What Is Windows Workflow Foundation?
Why Use Windows Workflow?
Workflow Concepts
Activities
Control Flow Activities
Expressions
Workflow Run Time/Scheduler
Bookmarks
Persistence
Tracking
Getting Started
The Workflow Foundation Designer
Creating a Workflow
Designing a Workflow
621
623
625
628
633
637
639
639
640
640
640
642
642
642
642
643
643
644
646
649
649
xxvii
www.it-ebooks.info
CONTENTS
Writing Code Activities
Executing a Workflow
Debugging Workflows
Testing Workflows
651
653
655
655
Hosting the Workflow Designer
Summary
CHAPTER 34: CLIENT APPLICATION SERVICES
Client Services
Role Authorization
User Authentication
Settings
Login Form
Offline Support
Summary
656
660
661
661
664
666
668
672
674
677
CHAPTER 35: SYNCHRONIZATION SERVICES
Occasionally Connected Applications
Server Direct
Getting Started with Synchronization Services
Synchronization Services over N-Tiers
Summary
CHAPTER 36: WCF RIA SERVICES
Getting Started
Domain Services
Domain Operations
679
679
680
683
687
688
689
689
691
693
Query Operations
Insert/Update/Delete Operations
Other Operation Types
Consuming a Domain Service
in Silverlight
Summary
694
694
694
695
699
PART VIII: CONFIGURATION AND RESOURCES
CHAPTER 37: CONFIGURATION FILES
.Config Files
703
703
Machine.Config
Web.Config
703
703
xxviii
www.it-ebooks.info
CONTENTS
App.Config
Security.Config
ApplicationHost.Config
704
704
704
Configuration Schema
705
Section: configurationSections
Section: startup
Section: runtime
Section: system.runtime.remoting
Section: system.net
Section: cryptographySettings
Section: system.diagnostics
Section: system.web
Section: compiler
Configuration Attributes
Application Settings
705
706
706
707
707
708
708
708
709
709
710
Using appSettings
Project Settings
Dynamic Properties
Custom Configuration Sections
710
711
712
713
User Settings
Referenced Projects with Settings
Summary
717
718
720
CHAPTER 38: CONNECTION STRINGS
721
Connection String Wizard
SQL Server Format
In-Code Construction
Encrypting Connection Strings
LocalDB
Summary
CHAPTER 39: RESOURCE FILES
What Are Resources?
721
725
726
728
729
730
731
731
Text File Resources
Resx Resource Files
Binary Resources
Adding Resources
Embedding Files as Resources
Naming Resources
Accessing Resources
732
733
734
734
735
735
735
xxix
www.it-ebooks.info
CONTENTS
Designer Files
736
Resourcing Your Application
737
Control Images
738
Satellite Resources
739
Cultures
Creating Culture Resources
Loading Culture Resource Files
Satellite Culture Resources
Accessing Specifics
739
740
740
741
741
Bitmap and Icon Loading
Cross-Assembly Referencing
ComponentResourceManager
Coding Resource Files
741
742
742
743
ResourceReader and ResourceWriter
ResxResourceReader and ResxResourceWriter
Custom Resources
Summary
743
744
744
747
PART IX: DEBUGGING
CHAPTER 40: USING THE DEBUGGING WINDOWS
The Code Window
751
751
Breakpoints
DataTips
752
752
The Breakpoints Window
The Output Window
The Immediate Window
The Watch Windows
QuickWatch
Watch Windows 1–4
Autos and Locals
752
753
754
755
756
756
757
The Code Execution Windows
Call Stack
Threads
Modules
Processes
757
757
758
758
759
The Memory Windows
759
Memory Windows 1–4
Disassembly
Registers
760
760
761
IntelliTrace (Ultimate Edition Only)
xxx
www.it-ebooks.info
761
CONTENTS
The Parallel Debugging Windows
Parallel Stacks
Parallel Tasks
762
762
764
Exceptions
765
Customizing the Exception Assistant
Unwinding an Exception
Summary
766
767
768
CHAPTER 41: DEBUGGING WITH BREAKPOINTS
Breakpoints
769
769
Setting a Breakpoint
Adding Break Conditions
Working with Breakpoints
770
772
774
Tracepoints
775
Creating a Tracepoint
Output Messages
776
776
Execution Control
776
Stepping Through Code
Moving the Execution Point
777
778
Edit and Continue
778
Rude Edits
Stop Applying Changes
779
779
Summary
779
CHAPTER 42: DATATIPS, DEBUG PROXIES, AND VISUALIZERS
DataTips
Debugger Attributes
781
781
783
DebuggerBrowsable
DebuggerDisplay
DebuggerHidden
DebuggerStepThrough
DebuggerNonUserCode
DebuggerStepperBoundary
783
784
784
785
786
786
Type Proxies
786
Raw View
788
Visualizers
Advanced Techniques
788
790
Saving Changes to Your Object
Summary
790
792
xxxi
www.it-ebooks.info
CONTENTS
CHAPTER 43: DEBUGGING WEB APPLICATIONS
Debugging Server-Side ASP.NET Code
Web Application Exceptions
Edit and Continue
Error Handling
Debugging Client-Side JavaScript
Setting Breakpoints in JavaScript Code
Debugging Dynamically Generated JavaScript
Debugging ASP.NET AJAX JavaScript
The Page Inspector
Debugging Silverlight
Tracing
793
794
796
798
798
799
799
800
801
801
802
804
Page-Level Tracing
Application-Level Tracing
Trace Output
The Trace Viewer
Custom Trace Output
Health Monitoring
Summary
804
805
806
806
807
807
809
CHAPTER 44: ADVANCED DEBUGGING TECHNIQUES
Start Actions
Debugging with Code
811
811
813
The Debugger Class
The Debug and Trace Classes
814
814
Debugging Running Applications
815
Attaching to a Windows Process
Attaching to a Web Application
Remote Debugging
IntelliTrace
815
816
818
819
.NET Framework Source
Multithreaded and Parallelized Application Debugging
Debugging SQL Server Stored Procedures
Mixed-Mode Debugging
Post-Mortem Debugging
Generating Dump Files
Debugging Dump Files
820
823
825
825
826
826
827
Summary
828
xxxii
www.it-ebooks.info
CONTENTS
PART X: BUILD AND DEPLOYMENT
CHAPTER 45: UPGRADING WITH VISUAL STUDIO 2012
831
Upgrading from Visual Studio 2010
Upgrading to .NET Framework 4.5
Summary
831
833
835
CHAPTER 46: BUILD CUSTOMIZATION
837
General Build Options
Manual Dependencies
The Visual Basic Compile Page
837
840
840
Advanced Compiler Settings
Build Events
841
843
C# Build Pages
MSBuild
845
846
How Visual Studio Uses MSBuild
The MSBuild Schema
Assembly Versioning via MSBuild Tasks
Summary
846
849
850
851
CHAPTER 47: ASSEMBLY VERSIONING AND SIGNING
Assembly Naming
Version Consistency
Strongly Named Assemblies
The Global Assembly Cache
Signing an Assembly
Summary
CHAPTER 48: OBFUSCATION, APPLICATION MONITORING, AND
MANAGEMENT
The MSIL Disassembler
Decompilers
Obfuscating Your Code
853
853
856
857
858
858
860
861
861
863
864
Dotfuscator and Analytics
Obfuscation Attributes
Words of Caution
864
868
870
Application Monitoring and Management
Tamper Defense
Runtime Intelligence Instrumentation and Analytics
Application Expiry
872
873
875
878
xxxiii
www.it-ebooks.info
CONTENTS
Application Usage Tracking
Summary
879
880
CHAPTER 49: PACKAGING AND DEPLOYMENT
Windows Installer XML Toolset
Building an Installer
Using Heat to Create Fragments
The Service Installer
ClickOnce
881
882
882
885
888
888
One Click to Deploy
One Click to Update
889
893
Summary
894
CHAPTER 50: WEB APPLICATION DEPLOYMENT
895
Website Deployment
895
Publish Web Site
Copy Web Site
895
897
Web Application Deployment
897
Publishing a Web Application
898
Web Project Installers
The Web Platform Installer
Extending the Web Platform Installer
Summary
900
901
902
905
PART XI: CUSTOMIZING AND EXTENDING VISUAL STUDIO
CHAPTER 51: THE AUTOMATION MODEL
909
Visual Studio Extensibility Options
The Visual Studio Automation Model
909
910
An Overview of the Automation Model
Solutions and Projects
Windows and Documents
Commands
Debugger
Events
910
912
912
914
915
916
Summary
916
CHAPTER 52: ADD-INS
917
Developing an Add-in
917
The Add-in Wizard
917
xxxiv
www.it-ebooks.info
CONTENTS
Project Structure
Testing Your Add-in
The .AddIn File
The Connect Class
Creating a Tool Window
Accessing the Visual Studio Automation Model
Handling Visual Studio Events
Deploying Add-ins
Summary
920
920
922
923
923
926
927
930
930
CHAPTER 53: MANAGED EXTENSIBILITY FRAMEWORK (MEF)
Getting Started with MEF
931
932
Imports and Exports
Contracts
Catalogs
Advanced MEF
933
935
936
937
The Visual Studio Editor
938
The Text Model Subsystem
The Text View Subsystem
The Classification Subsystem
The Operations Subsystem
Extending the Editor
938
938
939
939
939
Editor Extension Points
Editor Services
The Check Comment Highlighter Extension
Summary
941
944
944
950
PART XII: VISUAL STUDIO ULTIMATE
CHAPTER 54: VISUAL STUDIO ULTIMATE FOR ARCHITECTS
Modeling Projects
953
953
UML Diagrams
UML Model Explorer
Using Layer Diagrams to Verify Application Architecture
Linking to Team Foundation Server
Exploring Code
954
958
958
960
960
The Architecture Explorer
Dependency Graphs
Generate Sequence Diagram
Summary
960
962
962
964
xxxv
www.it-ebooks.info
CONTENTS
CHAPTER 55: VISUAL STUDIO ULTIMATE FOR DEVELOPERS
Code Metrics
965
965
Lines of Code
Depth of Inheritance
Class Coupling
Cyclomatic Complexity
Maintainability Index
Excluded Code
966
967
967
967
967
967
Managed Code Analysis Tool
C/C++ Code Analysis Tool
Profiling Tools
Configuring Profiler Sessions
Reports
Standalone Profiler
IntelliTrace
Database Tools
968
969
969
970
971
972
973
974
Database Schemas
SQL-CLR Support
Database Refactoring
Schema Compare
Static Analysis
Transact-SQL Editor
Best Practices
974
976
978
979
980
980
981
Summary
981
CHAPTER 56: VISUAL STUDIO ULTIMATE FOR TESTERS
Automated Tests
983
983
Web Performance Tests
Load Tests
Coded UI Test
Generic Tests
Ordered Test
984
987
988
989
989
Relating Code and Tests
989
Code Coverage
990
Visual Studio Test Management
Microsoft Test Manager
Testing Center
Lab Center
992
992
993
995
Summary
996
xxxvi
www.it-ebooks.info
CONTENTS
CHAPTER 57: TEAM FOUNDATION SERVER
997
Team Project
Process Templates
Work Item Tracking
998
998
1001
Work Item Queries
Work Item Types
Adding Work Items
Work Item State
1001
1003
1003
1003
Excel and Project Integration
Excel
Project
1004
1004
1005
Version Control
1005
Working from Solution Explorer
Check Out
Check In
Resolve Conflicts
Working Offline
Label
History
Annotate
Shelve
Branch
Merge
Team Foundation Build
Reporting and Business Intelligence
Team Portal
Documents
Process Guidance
SharePoint Lists
Dashboards
1006
1007
1007
1008
1009
1010
1011
1012
1013
1013
1014
1015
1017
1018
1018
1018
1019
1019
Web Access
Summary
1020
1020
INDEX
1021
xxxvii
www.it-ebooks.info
www.it-ebooks.info
INTRODUCTION
THROUGHOUT ITS HISTORY, Visual Studio has incorporated the latest advances in Microsoft’s premier
programming languages (Visual Basic and C#) and this version is no different. But alongside support for
language features, is also continuing support for developers. In theory, it is possible to create any .NET
application using tools as simple as Notepad and a command-line window. But the typical developer
would never think to do so. The tools and utilities that come with Visual Studio do more to increase the
productivity of developers than any other single piece of software currently available. Visual Studio 2012 is
no different from previous versions in this respect. It includes a host of improvements and new features that
are aimed at making the life of a developer easier.
Visual Studio 2012 is an enormous product no matter which way you look at it. It can be intimidating to
newcomers and difficult for even experienced .NET developers to fi nd what they need. And that’s where this
book comes in. Professional Visual Studio 2012 looks at every major aspect of this developer tool, showing
you how to harness each feature and offering advice about how best to utilize the various components
effectively. It shows you the building blocks that make up Visual Studio 2012, breaking the user interface
down into manageable chunks for you to understand. It then expands on each of these components with
additional details about exactly how they work both in isolation and in conjunction with other parts of
Visual Studio 2012, along with tools that are not included in the out-of-the-box product, to make your
development efforts even more efficient.
WHO THIS BOOK IS FOR
Professional Visual Studio 2012 is for developers who are new to Visual Studio as well as those
programmers who have some experience but want to learn about features they may have previously
overlooked.
Even if you are familiar with the way previous versions of Visual Studio worked, you may want to at least
skim over Part I. These chapters deal with the basic constructs that make up the user interface. In the past,
the basic interface didn’t change much from version to version. But as soon as you launch Visual Studio
2012 for the fi rst time, you’ll notice that the user interface has gone through some significant changes. While
you can get by without Part I, some of the changes in Visual Studio 2012 can make you a more efficient
developer. And, after all, that’s what you’re looking to get out of this book.
If you’re just starting out, you’ll greatly benefit from the fi rst part, where basic concepts are explained and
you’re introduced to the user interface and how to customize it to suit your own style.
WHAT THIS BOOK COVERS
Microsoft Visual Studio 2012 is arguably the most advanced integrated development environment (IDE)
available for programmers today. It is based on a long history of programming languages and interfaces and
has been influenced by many different variations on the theme of development environments.
With Visual Studio 2012, Microsoft took a chance (and received some pushback) for its decision to revamp
the user interface. Existing developers will fi nd it off-putting at fi rst (although you do get used to it quickly
and will rarely miss what is no longer visible by default). But newcomers to Visual Studio will fi nd it much
easier to work with. This book covers the breadth of Visual Studio 2012. Along the way, you will become
more familiar and comfortable with the new interface.
www.it-ebooks.info
INTRODUCTION
Visual Studio 2012 comes in several versions: Express, Professional, Premium, and Ultimate. The majority
of this book deals with the Professional Edition of Visual Studio 2012, but some parts utilize features found
only in the Premium and Ultimate editions. If you haven’t used these editions before, read through Chapters
54 to 57 for an overview of the features they offer over and above the Professional Edition.
HOW THIS BOOK IS STRUCTURED
This book’s fi rst section is dedicated to familiarizing you with the core aspects of Visual Studio 2012.
Everything you need is contained in the fi rst five chapters, from the IDE structure and layout to the various
options and settings you can change to make the user interface synchronize with your own way of doing
things.
From there, the remainder of the book is broken into 11 parts:
➤
Getting Started: In this part, you learn how to take control of your projects and how to organize them
in ways that work with your own style.
➤
Digging Deeper: Though the many graphical components of Visual Studio that make a programmer’s
job easier are discussed in many places throughout this book, you often need help when you’re in the
process of actually writing code. This part deals with features that support the coding of applications
such as IntelliSense, code refactoring, and creating and running unit tests The .NET Framework
supports dynamic languages and strengthens feature parity between the two primary .NET languages,
C# and VB. This part covers these languages, as well as looking at a range of features that will help
you write better and more consistent code.
➤
Rich Client Applications and Web Applications: For support with building everything from Office
add-ins to cloud applications, Visual Studio enables you to develop applications for a wide range of
platforms. These two parts cover the application platforms that are supported within Visual Studio
2012, including ASP.NET and Office, WPF, Silverlight 5, and ASP.NET MVC. Also, Chapter 20 takes
a look into the support provided for the new Windows Store applications.
➤
Data: A large proportion of applications use some form of data storage. Visual Studio 2012 and the
.NET Framework include strong support for working with databases and other data sources. This
part examines how to use DataSets, the Visual Database Tools, LINQ, Synchronization Services, and
ADO.NET Entity Framework to build applications that work with data. It also shows you how you
can then present this data using Reporting.
➤
Application Services: Through the course of building an application, you are likely to require access to
services that may or may not reside within your organization. This part covers core technologies such
as WCF, WF, Synchronization Services, and WCF RIA services that you can use to connect to these
services.
➤
Configuration and Resources: The built-in support for configuration fi les allows you to adjust the way
an application functions on the fly without having to rebuild it. Furthermore, resource fi les can be
used to both access static data and easily localize an application into foreign languages and cultures.
This part of the book shows how to use .NET configuration and resource fi les.
➤
Debugging: Application debugging is one of the more challenging tasks developers have to tackle, but
correct use of the Visual Studio 2012 debugging features will help you analyze the state of the application and determine the cause of any bugs. This part examines the debugging support provided by the
IDE.
➤
Build and Deployment: In addition to discussing how to build your solutions effectively and getting
applications into the hands of your end users, this part also deals with the process of upgrading your
projects from previous versions.
xl
www.it-ebooks.info
INTRODUCTION
➤
Customizing and Extending Visual Studio: If the functionality found in the previous part isn’t enough
to help you in your coding efforts, Visual Studio 2012 is even more extensible. This part covers the
automation model, how to write add-ins, and then how to use the Microsoft Extensibility Framework
(MEF) to extend Visual Studio 2012.
➤
Visual Studio Ultimate: The fi nal part of the book examines the additional features only available in
the Premium and Ultimate versions of Visual Studio 2012. In addition, you’ll also learn how the Team
Foundation Server provides an essential tool for managing software projects.
Though this breakdown of the Visual Studio feature set provides the most logical and easily understood set
of topics, you may need to look for specific functions that will aid you in a particular activity. To address
this need, references to appropriate chapters are provided whenever a feature is covered in more detail
elsewhere in the book.
WHAT YOU NEED TO USE THIS BOOK
To use this book effectively, you’ll need only one additional item — Microsoft Visual Studio 2012
Professional Edition. With this software installed and the information found in this book, you’ll be able to
get a handle on how to use Visual Studio 2012 effectively in a very short period of time.
This book assumes that you are familiar with the traditional programming model, and it uses both the C#
and Visual Basic (VB) languages to illustrate features within Visual Studio 2012. In addition, it is assumed
that you can understand the code listings without an explanation of basic programming concepts in either
language. If you’re new to programming and want to learn Visual Basic, please take a look at Beginning
Visual Basic 2012 by Bryan Newsome. Similarly, if you are after a great book on C#, track down Beginning
Visual C# 2012, written collaboratively by a host of authors.
Some chapters discuss additional products and tools that work in conjunction with Visual Studio. The following are all available to download either on a trial basi
www.it-ebooks.info
PROFESSIONAL VISUAL STUDIO® 2012
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxix
⊲ PART I
INTEGRATED DEVELOPMENT ENVIRONMENT
CHAPTER 1
A Quick Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 2
The Solution Explorer, Toolbox, and Properties . . . . . . . . . . . . . . . . . . . . .13
CHAPTER 3
Options and Customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
CHAPTER 4
The Visual Studio Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
CHAPTER 5
Find and Replace and Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
⊲ PART II
GETTING STARTED
CHAPTER 6
Solutions, Projects, and Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
CHAPTER 7
IntelliSense and Bookmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
CHAPTER 8
Code Snippets and Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
CHAPTER 9
Server Explorer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
CHAPTER 10
Modeling with the Class Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
⊲ PART III
DIGGING DEEPER
CHAPTER 11
Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
CHAPTER 12
Documentation with XML Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
CHAPTER 13
Code Consistency Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
CHAPTER 14
Code Generation with T4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
CHAPTER 15
Project and Item Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
CHAPTER 16
Language-Specific Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
⊲ PART IV RICH CLIENT APPLICATIONS
CHAPTER 17
Windows Forms Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
CHAPTER 18
Windows Presentation Foundation (WPF) . . . . . . . . . . . . . . . . . . . . . . . . 305
CHAPTER 19
Office Business Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
CHAPTER 20
Windows Store Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Continues
www.it-ebooks.info
⊲ PART V
WEB APPLICATIONS
CHAPTER 21
ASP.NET Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
CHAPTER 22
ASP.NET MVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
CHAPTER 23
Silverlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 24
Dynamic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
CHAPTER 25
SharePoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
CHAPTER 26
Windows Azure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
⊲ PART VI DATA
CHAPTER 27
Visual Database Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
CHAPTER 28
DataSets and DataBinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
CHAPTER 29
Language Integrated Queries (LINQ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
CHAPTER 30
The ADO.NET Entity Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
CHAPTER 31
Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
⊲ PART VII APPLICATION SERVICES
CHAPTER 32
Windows Communication Foundation (WCF) . . . . . . . . . . . . . . . . . . . . . 619
CHAPTER 33
Windows Workflow Foundation (WF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
CHAPTER 34
Client Application Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
CHAPTER 35
Synchronization Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
CHAPTER 36
WCF RIA Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
⊲ PART VIII CONFIGURATION AND RESOURCES
CHAPTER 37
Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
CHAPTER 38
Connection Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
CHAPTER 39
Resource Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
⊲ PART IX DEBUGGING
CHAPTER 40
Using the Debugging Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .751
CHAPTER 41
Debugging with Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 769
CHAPTER 42
DataTips, Debug Proxies, and Visualizers . . . . . . . . . . . . . . . . . . . . . . . . 781
CHAPTER 43
Debugging Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
CHAPTER 44
Advanced Debugging Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 811
www.it-ebooks.info
⊲ PART X
BUILD AND DEPLOYMENT
CHAPTER 45
Upgrading with Visual Studio 2012. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
CHAPTER 46
Build Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
CHAPTER 47
Assembly Versioning and Signing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
CHAPTER 48
Obfuscation, Application Monitoring, and Management . . . . . . . . . . . 861
CHAPTER 49
Packaging and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
CHAPTER 50
Web Application Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
⊲ PART XI CUSTOMIZING AND EXTENDING VISUAL STUDIO
CHAPTER 51
The Automation Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .909
CHAPTER 52
Add-Ins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
CHAPTER 53
Managed Extensibility Framework (MEF) . . . . . . . . . . . . . . . . . . . . . . . . 931
⊲ PART XII VISUAL STUDIO ULTIMATE
CHAPTER 54
Visual Studio Ultimate for Architects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 953
CHAPTER 55
Visual Studio Ultimate for Developers . . . . . . . . . . . . . . . . . . . . . . . . . . . 965
CHAPTER 56
Visual Studio Ultimate for Testers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983
CHAPTER 57
Team Foundation Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1021
www.it-ebooks.info
www.it-ebooks.info
PROFESSIONAL
Visual Studio® 2012
Bruce Johnson
www.it-ebooks.info
Professional Visual Studio® 2012
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-33770-7
ISBN: 978-1-118-41648-8 (ebk)
ISBN: 978-1-118-43407-9 (ebk)
ISBN: 978-1-118-46390-1 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201)
748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold
with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services.
If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to
in this work as a citation and/or a potential source of further information does not mean that the author or the publisher
endorses the information the organization or Web site may provide or recommendations it may make. Further, readers
should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was
written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such
as a CD or DVD that is not included in the version you purchased, you may download this material at
http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2012944689
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may not be used without written permission. Visual Studio is a registered trademark of Microsoft Corporation.
All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any
product or vendor mentioned in this book.
www.it-ebooks.info
I’d like to thank my wife, Ali, and my four children,
Kyle, Cameron, Gillian, and Curtis, for their love
and support. While they might not have written any
of the words directly, they certainly helped create an
environment where I could get my ideas out my head
and into the computer.
— Bruce Johnson
www.it-ebooks.info
CREDITS
ACQUISITIONS EDITOR
PRODUCTION MANAGER
Mary James
Tim Tate
PROJECT EDITOR
VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER
Kelly Talbot
Richard Swadley
TECHNICAL EDITORS
Joe Bennett
Andrew Moore
VICE PRESIDENT AND EXECUTIVE PUBLISHER
PRODUCTION EDITOR
ASSOCIATE PUBLISHER
Christine Mugnolo
Jim Minatel
COPY EDITOR
PROJECT COORDINATOR, COVER
San Dee Phillips
Katie Crocker
EDITORIAL MANAGER
PROOFREADERS
Mary Beth Wakefield
Jennifer Bennett, Word One New York
Scott Klemp, Word One New York
James Saturnio, Word One New York
Neil Edde
FREELANCER EDITORIAL MANAGER
Rosemarie Graham
INDEXER
ASSOCIATE DIRECTOR OF MARKETING
Johnna VanHoose Dinse
David Mayhew
COVER DESIGNER
MARKETING MANAGER
LeAndra Young
Ashley Zurcher
COVER IMAGE
BUSINESS MANAGER
© Eric Delmar / iStockPhoto
Amy Knies
www.it-ebooks.info
ABOUT THE AUTHOR
BRUCE JOHNSON is a partner at ObjectSharp Consulting and a 30-year veteran of the computer industry.
The fi rst third of his career was spent doing “real work,” otherwise known as coding in the UNIX world.
But for almost 20 years, he has been working on projects that are at the leading edge of Windows technology, from C++ through Visual Basic to C#, and from thick client applications to websites to services.
As well as having fun with building systems, Bruce has spoken hundreds of times at conferences
and user groups throughout North America. He has been a Microsoft Certified Trainer (MCT)
for the past three years and he is a co-president of the Metro Toronto .NET User Group. He has also
written columns and articles for numerous magazines. While the quantity of the posts on his blog
(http://blogs.objectsharp.com/author/bruce.aspx) has decreased recently, the activity on his
Twitter account (http://www.twitter.com/lacanuck) has shown a corresponding increase. For all of this
activity (or, perhaps, in spite of it), Bruce has been privileged to be recognized as a Microsoft MVP
for the past six years.
www.it-ebooks.info
www.it-ebooks.info
ACKNOWLEDGMENTS
TO THE OUTSIDE, it might look like the writing of a book is an individual effort. Having gone through this
act of creation a number of times, I can tell you that nothing is further from the truth. Yes, there is a lot of
effort on the part of the author (and the feeling of joy you get as you hand in your last rewrite is quite palpable). But I can also tell you that without the rarely acknowledged efforts of the others involved in the editorial process, the book would never have made it to completion. And if you, as the reader, take something
useful from this book, odds are that my editor, my technical reviewer, and the project editor are the reason
why.
I would especially like to thank everyone at Wrox who has helped me through this process. In particular,
thanks go out to Kelly Talbot, whose patience and attention to detail are quite impressive. Thanks also go to
Andrew Moore and Joe Bennett, who did a great job making sure that the technical details of the book were
accurate. Finally, thanks to San Dee Phillips, who had the unenviable chore of ensuring that I wasn’t writing in the passive voice and fi xed it when I stopped writing so well. The efforts of all of these individuals are
what make the book possible and, hopefully, a success. Thanks also to Mary James, who was kind enough
to take a chance on my ability to write.
Lastly, I would like to thank all of my associates at ObjectSharp and the people at Microsoft who, although
they might not have realized it, were keeping the writing process going by answering any questions I had.
— Bruce Johnson
www.it-ebooks.info
www.it-ebooks.info
CONTENTS
INTRODUCTION
xxxix
PART I: INTEGRATED DEVELOPMENT ENVIRONMENT
CHAPTER 1: A QUICK TOUR
3
Getting Started
3
Installing Visual Studio 2012
Running Visual Studio 2012
3
4
The Visual Studio IDE
5
Developing, Building, Debugging, and Deploying
Your First Application
Summary
7
12
CHAPTER 2: THE SOLUTION EXPLORER, TOOLBOX, AND PROPERTIES 13
The Solution Explorer
13
Previewing Files
Common Tasks
15
16
The Toolbox
21
Arranging Components
Adding Components
23
24
Properties
25
Extending the Properties Window
Summary
27
30
CHAPTER 3: OPTIONS AND CUSTOMIZATIONS
The Start Page
31
31
Customizing the Start Page
32
Window Layout
32
Viewing Windows and Toolbars
Navigating Open Items
Docking
The Editor Space
33
33
34
37
Fonts and Colors
Visual Guides
Full-Screen Mode
Tracking Changes
38
38
40
40
www.it-ebooks.info
CONTENTS
Other Options
41
Keyboard Shortcuts
Quick Launch
Projects and Solutions
Build and Run
VB Options
41
42
43
44
45
Importing and Exporting Settings
Summary
CHAPTER 4: THE VISUAL STUDIO WORKSPACE
The Code Editor
45
47
49
49
The Code Editor Window Layout
Regions
Outlining
Code Formatting
Navigating Forward/Backward
Additional Code Editor Features
Split View
Tear Away (Floating) Code Windows
Duplicating Solution Explorer
Creating Tab Groups
Advanced Functionality
49
50
51
51
53
53
53
54
55
56
56
The Command Window
The Immediate Window
The Class View
The Error List
The Object Browser
The Code Definition Window
The Call Hierarchy Window
The Document Outline Tool Window
58
59
59
60
61
61
62
63
HTML Outlining
Control Outlining
63
64
Reorganizing Tool Windows
Summary
CHAPTER 5: FIND AND REPLACE AND HELP
Quick Find/Replace
66
66
67
67
Quick Find
Quick Replace
Find Options
68
69
69
xiv
www.it-ebooks.info
CONTENTS
Find and Replace Options
70
Find/Replace in Files
70
Find in Files
Find Dialog Options
Regular Expressions
Results Window
Replace in Files
70
71
72
73
74
Navigate To
Accessing Help
74
75
Navigating and Searching the Help System
Configuring the Help System
Summary
76
77
77
PART II: GETTING STARTED
CHAPTER 6: SOLUTIONS, PROJECTS, AND ITEMS
Solution Structure
Solution File Format
Solution Properties
81
81
83
83
Common Properties
Configuration Properties
84
85
Project Types
Project Files Format
Project Properties
86
88
88
Application
Compile (Visual Basic Only)
Build (C# and F# Only)
Build Events (C# and F# Only)
Debug
References (Visual Basic Only)
Resources
Services
Settings
Reference Paths (C# and F# Only)
Signing
My Extensions (Visual Basic Only)
Security
Publish
Code Analysis
89
92
93
94
94
96
97
97
98
99
100
100
101
102
102
xv
www.it-ebooks.info
CONTENTS
Web Application Project Properties
Web
Silverlight Applications
Package/Publish Web
Package/Publish SQL
103
103
104
105
106
Web Site Projects
Summary
107
107
CHAPTER 7: INTELLISENSE AND BOOKMARKS
IntelliSense Explained
109
109
General IntelliSense
IntelliSense and C++
Completing Words and Phrases
Parameter Information
Quick Info
JavaScript IntelliSense
110
111
111
116
117
117
The JavaScript IntelliSense Context
Referencing Another JavaScript File
IntelliSense Options
118
118
119
General Options
Statement Completion
C#-Specific Options
119
121
121
Extended IntelliSense
122
Code Snippets
XML Comments
Adding Your Own IntelliSense
Bookmarks and the Bookmark Window
Summary
CHAPTER 8: CODE SNIPPETS AND REFACTORING
Code Snippets Revealed
122
123
123
123
125
127
128
Storing Code Blocks in the Toolbox
Code Snippets
Using Snippets in C#
Using Snippets in VB
Surround With Snippet
Code Snippets Manager
Creating Snippets
Reviewing Existing Snippets
Accessing Refactoring Support
xvi
www.it-ebooks.info
128
129
129
130
131
132
133
133
136
CONTENTS
Refactoring Actions
137
Extract Method
Encapsulate Field
Extract Interface
Reorder Parameters
Remove Parameters
Rename
Generate Method Stub
Organize Usings
137
140
140
143
143
144
145
145
Summary
146
CHAPTER 9: SERVER EXPLORER
Server Connections
147
147
Event Logs
Management Classes
Management Events
Message Queues
Performance Counters
Services
148
150
152
154
156
159
Data Connections
SharePoint Connections
Summary
160
160
161
CHAPTER 10: MODELING WITH THE CLASS DESIGNER
Creating a Class Diagram
The Design Surface
The Toolbox
163
163
164
165
Entities
Connectors
165
166
The Class Details
The Properties Window
Layout
Exporting Diagrams
Code Generation and Refactoring
Drag-and-Drop Code Generation
IntelliSense Code Generation
Refactoring with the Class Designer
Modeling Power Toys for Visual Studio
Visualization Enhancements
Functionality Enhancements
166
167
168
168
169
169
171
171
172
172
173
Summary
174
xvii
www.it-ebooks.info
CONTENTS
PART III: DIGGING DEEPER
CHAPTER 11: UNIT TESTING
Your First Test Case
177
177
Identifying Tests Using Attributes
Additional Test Attributes
Asserting the Facts
183
183
185
The Assert Class
The StringAssert Class
The CollectionAssert Class
The ExpectedException Attribute
Initializing and Cleaning Up
TestInitialize and TestCleanup
ClassInitialize and ClassCleanup
AssemblyInitialize and AssemblyCleanup
Testing Context
185
186
186
186
188
188
188
188
189
Data
Writing Test Output
189
191
Advanced Unit Testing
192
Custom Properties
Testing Private Members
192
193
Testing Code Contracts
Summary
194
196
CHAPTER 12: DOCUMENTATION WITH XML COMMENTS
Inline Commenting
XML Comments
197
197
198
Adding XML Comments
XML Comment Tags
198
199
Using XML Comments
211
IntelliSense Information
212
Generating Documentation with GhostDoc
Compiling Documentation with Sandcastle
Task List Comments
Summary
CHAPTER 13: CODE CONSISTENCY TOOLS
Source Control
212
214
216
218
219
219
Selecting a Source Control Repository
Accessing Source Control
xviii
www.it-ebooks.info
220
222
CONTENTS
Coding Standards
226
Code Analysis with FxCop
Style Using StyleCop
Code Contracts
226
229
230
Summary
232
CHAPTER 14: CODE GENERATION WITH T4
233
Creating a T4 Template
T4 Building Blocks
233
236
Expression Blocks
Statement Blocks
Class Feature Blocks
237
237
239
How T4 Works
T4 Directives
240
242
Template Directive
Output Directive
Assembly Directive
Import Directive
Include Directive
242
243
243
243
244
Troubleshooting
245
Design-Time Errors
Compiling Transformation Errors
Executing Transformation Errors
Generated Code Errors
Generating Code Assets
Runtime Text Templates
245
245
246
246
246
250
Using Runtime Text Templates
251
Differences Between Runtime Text Templates and Standard T4 Templates 253
Tips and Tricks
Summary
254
255
CHAPTER 15: PROJECT AND ITEM TEMPLATES
Creating Templates
257
257
Item Template
Project Template
Template Structure
Template Parameters
Template Locations
257
261
262
263
265
Extending Templates
265
Template Project Setup
265
xix
www.it-ebooks.info
CONTENTS
IWizard
Generating the Extended Project Template
Starter Kits
Online Templates
Summary
266
271
272
273
273
CHAPTER 16: LANGUAGE-SPECIFIC FEATURES
Hitting a Nail with the Right Hammer
Imperative
Declarative
Dynamic
Functional
What’s It All Mean?
275
275
276
276
276
277
277
A Tale of Two Languages
278
The Async Keyword
Caller Information
278
280
Visual Basic
281
Iterators
The Global Keyword
Visual Basic PowerPacks
281
281
282
F#
283
Your First F# Program
Exploring F# Language Features
Type Providers
Query Expressions
Auto-Implemented Properties
Summary
283
285
287
287
288
288
PART IV: RICH CLIENT APPLICATIONS
CHAPTER 17: WINDOWS FORMS APPLICATIONS
Getting Started
The Windows Form
291
291
292
Appearance Properties
Layout Properties
Window Style Properties
293
293
293
Form Design Preferences
Adding and Positioning Controls
Vertically Aligning Text Controls
Automatic Positioning of Multiple Controls
xx
www.it-ebooks.info
294
296
297
297
CONTENTS
Tab Order and Layering Controls
Locking Control Design
Setting Control Properties
Service-Based Components
Smart Tag Tasks
Container Controls
298
299
299
300
301
301
Panel and SplitContainer
FlowLayoutPanel
TableLayoutPanel
301
302
303
Docking and Anchoring Controls
Summary
CHAPTER 18: WINDOWS PRESENTATION FOUNDATION (WPF)
303
304
305
What Is WPF?
Getting Started with WPF
305
307
XAML Fundamentals
The WPF Controls
The WPF Layout Controls
309
310
311
The WPF Designer and XAML Editor
Working with the XAML Editor
Working with the WPF Designer
The Properties Tool Window
Data Binding Features
Styling Your Application
Windows Forms Interoperability
Hosting a WPF Control in Windows Forms
Hosting a Windows Forms Control in WPF
Debugging with the WPF Visualizer
Summary
CHAPTER 19: OFFICE BUSINESS APPLICATIONS
Choosing an Office Project Type
Document-Level Customizations
Application-Level Add-ins
Creating a Document-Level Customization
Your First VSTO Project
Protecting the Document Design
Adding an Actions Pane
Creating an Application Add-in
Some Outlook Concepts
313
314
315
317
321
324
325
326
327
328
330
331
331
332
333
333
333
336
337
338
338
xxi
www.it-ebooks.info
CONTENTS
Creating an Outlook Form Region
Debugging Office Applications
Unregistering an Add-in
Disabled Add-ins
339
343
343
344
Deploying Office Applications
Summary
CHAPTER 20: WINDOWS STORE APPLICATIONS
What Is a Windows Store Application?
Content Before Chrome
Snap and Scale
Semantic Zoom
Contracts
Tiles
Embrace the Cloud
345
346
347
347
348
349
349
349
350
350
Creating a Windows Store Application
The Windows 8 Simulator
Your Windows Store Application
Summary
350
353
355
358
PART V: WEB APPLICATIONS
CHAPTER 21: ASP.NET WEB FORMS
Web Application Versus Web Site Projects
Creating Web Projects
Creating a Web Site Project
Creating a Web Application Project
Other Web Projects
Starter Kits, Community Projects, and Open-Source Applications
Designing Web Forms
361
362
362
363
366
367
368
368
The HTML Designer
Positioning Controls and HTML Elements
Formatting Controls and HTML Elements
CSS Tools
Validation Tools
Web Controls
368
370
372
372
376
377
Navigation Components
User Authentication
Data Components
Web Parts
377
378
379
382
xxii
www.it-ebooks.info
CONTENTS
Master Pages
Rich Client-Side Development
383
385
Developing with JavaScript
Working with ASP.NET AJAX
Using AJAX Control Extenders
385
386
388
ASP.NET Web Site Administration
390
Security
Application Settings
ASP.NET Configuration in IIS
391
393
393
Summary
394
CHAPTER 22: ASP.NET MVC
395
Model View Controller
Getting Started with ASP.NET MVC
Choosing a Model
Controllers and Action Methods
MVC Scaffolding
396
396
398
399
399
Rendering a UI with Views
Advanced MVC
402
409
Routing
Action Method Parameters
Areas
Validation
Partial Views
Dynamic Data Templates
jQuery
409
412
415
417
419
419
422
Summary
424
CHAPTER 23: SILVERLIGHT
425
What Is Silverlight?
Getting Started with Silverlight
Navigation Framework
Theming
Enabling Running Out of Browser
Summary
CHAPTER 24: DYNAMIC DATA
425
426
432
433
435
438
439
Creating a Dynamic Data Web Application
Adding a Data Model
Exploring a Dynamic Data Application
440
441
443
xxiii
www.it-ebooks.info
CONTENTS
Customizing the Data Model
Scaffolding Individual Tables
Customizing Individual Data Fields
Adding Custom Validation Rules
Customizing the Display Format
Customizing the Presentation
Page Templates
Field Templates
Entity Templates
Filter Templates
444
445
445
447
448
449
450
453
455
457
Enabling Dynamic Data for Existing Projects
Summary
CHAPTER 25: SHAREPOINT
Preparing the Development Environment
Installing the Prerequisites
Installing SharePoint 2010
Exploring SharePoint 2010
Creating a SharePoint Project
Building Custom SharePoint Components
Developing Web Parts
Creating Content Types and Lists
Adding Event Receivers
Creating SharePoint Workflows
460
460
461
462
462
464
465
467
471
471
472
475
476
Working with Features
Packaging and Deployment
Summary
478
480
481
CHAPTER 26: WINDOWS AZURE
483
The Windows Azure Platform
484
The Compute Emulator
Table, Blob, and Queue Storage
Application Deployment
SQL Azure
AppFabric
486
487
490
494
496
Service Bus
Access Control Service
496
496
Azure Websites
Azure Virtual Machines
496
497
Connectivity
497
Summary
498
xxiv
www.it-ebooks.info
CONTENTS
PART VI: DATA
CHAPTER 27: VISUAL DATABASE TOOLS
Database Windows in Visual Studio 2012
Server Explorer
The Data Sources Window
SQL Server Object Explorer
501
501
502
506
506
Editing Data
Summary
507
508
CHAPTER 28: DATASETS AND DATABINDING
DataSets Overview
509
509
Adding a Data Source
The DataSet Designer
510
511
Binding Data
514
BindingSource
BindingNavigator
Data Source Selections
Saving Changes
Inserting New Items
Validation
Customized DataSets
BindingSource Chains and the DataGridView
Working with Data Sources
516
518
519
521
523
524
525
527
529
The Web Service Data Source
Browsing Data
Summary
531
532
534
CHAPTER 29: LANGUAGE INTEGRATED QUERIES (LINQ)
535
LINQ Providers
Old-School Queries
Query Pieces
535
536
538
From
Select
Where
Group By
Custom Projections
Order By
538
539
539
540
541
541
Debugging and Execution
LINQ to XML
542
543
xxv
www.it-ebooks.info
CONTENTS
VB XML Literals
Creating XML with LINQ
544
544
Querying XML
Schema Support
LINQ to SQL
546
547
549
Creating the Object Model
Querying with LINQ to SQL
Binding LINQ to SQL Objects
LINQPad
Summary
549
551
556
558
559
CHAPTER 30: THE ADO.NET ENTITY FRAMEWORK
What Is the Entity Framework?
Comparison with LINQ to SQL
Entity Framework Concepts
Getting Started
Creating an Entity Model
561
562
562
562
563
563
The Entity Data Model Wizard
The Entity Framework Designer
Creating/Modifying Entities
Creating/Modifying Entity Associations
Entity Inheritance
Validating an Entity Model
Updating an Entity Model with Database Changes
Querying the Entity Model
LINQ to Entities Overview
Getting an Object Context
CRUD Operations
Navigating Entity Associations
Advanced Functionality
564
567
571
573
574
574
574
575
575
576
576
580
581
Updating a Database from an Entity Model
Adding Business Logic to Entities
Plain Old CLR Objects (POCO)
Summary
581
582
582
582
CHAPTER 31: REPORTING
583
Getting Started with Reporting
Designing Reports
Defining Data Sources
Reporting Controls
583
585
586
588
xxvi
www.it-ebooks.info
CONTENTS
Expressions, Placeholders, and Aggregates
Custom Code
Report Layout
Subreports
The Report Wizard
Rendering Reports
600
604
608
609
611
612
The Report Viewer Controls
Generating the Report
Rendering Reports to Different Formats
Deploying Reports
Summary
612
613
614
615
616
PART VII: APPLICATION SERVICES
CHAPTER 32: WINDOWS COMMUNICATION FOUNDATION (WCF)
What Is WCF?
Getting Started
Defining Contracts
619
619
620
621
Creating the Service Contract
Creating the Data Contract
Configuring WCF Service Endpoints
Hosting WCF Services
Consuming a WCF Service
Summary
CHAPTER 33: WINDOWS WORKFLOW FOUNDATION (WF)
What Is Windows Workflow Foundation?
Why Use Windows Workflow?
Workflow Concepts
Activities
Control Flow Activities
Expressions
Workflow Run Time/Scheduler
Bookmarks
Persistence
Tracking
Getting Started
The Workflow Foundation Designer
Creating a Workflow
Designing a Workflow
621
623
625
628
633
637
639
639
640
640
640
642
642
642
642
643
643
644
646
649
649
xxvii
www.it-ebooks.info
CONTENTS
Writing Code Activities
Executing a Workflow
Debugging Workflows
Testing Workflows
651
653
655
655
Hosting the Workflow Designer
Summary
CHAPTER 34: CLIENT APPLICATION SERVICES
Client Services
Role Authorization
User Authentication
Settings
Login Form
Offline Support
Summary
656
660
661
661
664
666
668
672
674
677
CHAPTER 35: SYNCHRONIZATION SERVICES
Occasionally Connected Applications
Server Direct
Getting Started with Synchronization Services
Synchronization Services over N-Tiers
Summary
CHAPTER 36: WCF RIA SERVICES
Getting Started
Domain Services
Domain Operations
679
679
680
683
687
688
689
689
691
693
Query Operations
Insert/Update/Delete Operations
Other Operation Types
Consuming a Domain Service
in Silverlight
Summary
694
694
694
695
699
PART VIII: CONFIGURATION AND RESOURCES
CHAPTER 37: CONFIGURATION FILES
.Config Files
703
703
Machine.Config
Web.Config
703
703
xxviii
www.it-ebooks.info
CONTENTS
App.Config
Security.Config
ApplicationHost.Config
704
704
704
Configuration Schema
705
Section: configurationSections
Section: startup
Section: runtime
Section: system.runtime.remoting
Section: system.net
Section: cryptographySettings
Section: system.diagnostics
Section: system.web
Section: compiler
Configuration Attributes
Application Settings
705
706
706
707
707
708
708
708
709
709
710
Using appSettings
Project Settings
Dynamic Properties
Custom Configuration Sections
710
711
712
713
User Settings
Referenced Projects with Settings
Summary
717
718
720
CHAPTER 38: CONNECTION STRINGS
721
Connection String Wizard
SQL Server Format
In-Code Construction
Encrypting Connection Strings
LocalDB
Summary
CHAPTER 39: RESOURCE FILES
What Are Resources?
721
725
726
728
729
730
731
731
Text File Resources
Resx Resource Files
Binary Resources
Adding Resources
Embedding Files as Resources
Naming Resources
Accessing Resources
732
733
734
734
735
735
735
xxix
www.it-ebooks.info
CONTENTS
Designer Files
736
Resourcing Your Application
737
Control Images
738
Satellite Resources
739
Cultures
Creating Culture Resources
Loading Culture Resource Files
Satellite Culture Resources
Accessing Specifics
739
740
740
741
741
Bitmap and Icon Loading
Cross-Assembly Referencing
ComponentResourceManager
Coding Resource Files
741
742
742
743
ResourceReader and ResourceWriter
ResxResourceReader and ResxResourceWriter
Custom Resources
Summary
743
744
744
747
PART IX: DEBUGGING
CHAPTER 40: USING THE DEBUGGING WINDOWS
The Code Window
751
751
Breakpoints
DataTips
752
752
The Breakpoints Window
The Output Window
The Immediate Window
The Watch Windows
QuickWatch
Watch Windows 1–4
Autos and Locals
752
753
754
755
756
756
757
The Code Execution Windows
Call Stack
Threads
Modules
Processes
757
757
758
758
759
The Memory Windows
759
Memory Windows 1–4
Disassembly
Registers
760
760
761
IntelliTrace (Ultimate Edition Only)
xxx
www.it-ebooks.info
761
CONTENTS
The Parallel Debugging Windows
Parallel Stacks
Parallel Tasks
762
762
764
Exceptions
765
Customizing the Exception Assistant
Unwinding an Exception
Summary
766
767
768
CHAPTER 41: DEBUGGING WITH BREAKPOINTS
Breakpoints
769
769
Setting a Breakpoint
Adding Break Conditions
Working with Breakpoints
770
772
774
Tracepoints
775
Creating a Tracepoint
Output Messages
776
776
Execution Control
776
Stepping Through Code
Moving the Execution Point
777
778
Edit and Continue
778
Rude Edits
Stop Applying Changes
779
779
Summary
779
CHAPTER 42: DATATIPS, DEBUG PROXIES, AND VISUALIZERS
DataTips
Debugger Attributes
781
781
783
DebuggerBrowsable
DebuggerDisplay
DebuggerHidden
DebuggerStepThrough
DebuggerNonUserCode
DebuggerStepperBoundary
783
784
784
785
786
786
Type Proxies
786
Raw View
788
Visualizers
Advanced Techniques
788
790
Saving Changes to Your Object
Summary
790
792
xxxi
www.it-ebooks.info
CONTENTS
CHAPTER 43: DEBUGGING WEB APPLICATIONS
Debugging Server-Side ASP.NET Code
Web Application Exceptions
Edit and Continue
Error Handling
Debugging Client-Side JavaScript
Setting Breakpoints in JavaScript Code
Debugging Dynamically Generated JavaScript
Debugging ASP.NET AJAX JavaScript
The Page Inspector
Debugging Silverlight
Tracing
793
794
796
798
798
799
799
800
801
801
802
804
Page-Level Tracing
Application-Level Tracing
Trace Output
The Trace Viewer
Custom Trace Output
Health Monitoring
Summary
804
805
806
806
807
807
809
CHAPTER 44: ADVANCED DEBUGGING TECHNIQUES
Start Actions
Debugging with Code
811
811
813
The Debugger Class
The Debug and Trace Classes
814
814
Debugging Running Applications
815
Attaching to a Windows Process
Attaching to a Web Application
Remote Debugging
IntelliTrace
815
816
818
819
.NET Framework Source
Multithreaded and Parallelized Application Debugging
Debugging SQL Server Stored Procedures
Mixed-Mode Debugging
Post-Mortem Debugging
Generating Dump Files
Debugging Dump Files
820
823
825
825
826
826
827
Summary
828
xxxii
www.it-ebooks.info
CONTENTS
PART X: BUILD AND DEPLOYMENT
CHAPTER 45: UPGRADING WITH VISUAL STUDIO 2012
831
Upgrading from Visual Studio 2010
Upgrading to .NET Framework 4.5
Summary
831
833
835
CHAPTER 46: BUILD CUSTOMIZATION
837
General Build Options
Manual Dependencies
The Visual Basic Compile Page
837
840
840
Advanced Compiler Settings
Build Events
841
843
C# Build Pages
MSBuild
845
846
How Visual Studio Uses MSBuild
The MSBuild Schema
Assembly Versioning via MSBuild Tasks
Summary
846
849
850
851
CHAPTER 47: ASSEMBLY VERSIONING AND SIGNING
Assembly Naming
Version Consistency
Strongly Named Assemblies
The Global Assembly Cache
Signing an Assembly
Summary
CHAPTER 48: OBFUSCATION, APPLICATION MONITORING, AND
MANAGEMENT
The MSIL Disassembler
Decompilers
Obfuscating Your Code
853
853
856
857
858
858
860
861
861
863
864
Dotfuscator and Analytics
Obfuscation Attributes
Words of Caution
864
868
870
Application Monitoring and Management
Tamper Defense
Runtime Intelligence Instrumentation and Analytics
Application Expiry
872
873
875
878
xxxiii
www.it-ebooks.info
CONTENTS
Application Usage Tracking
Summary
879
880
CHAPTER 49: PACKAGING AND DEPLOYMENT
Windows Installer XML Toolset
Building an Installer
Using Heat to Create Fragments
The Service Installer
ClickOnce
881
882
882
885
888
888
One Click to Deploy
One Click to Update
889
893
Summary
894
CHAPTER 50: WEB APPLICATION DEPLOYMENT
895
Website Deployment
895
Publish Web Site
Copy Web Site
895
897
Web Application Deployment
897
Publishing a Web Application
898
Web Project Installers
The Web Platform Installer
Extending the Web Platform Installer
Summary
900
901
902
905
PART XI: CUSTOMIZING AND EXTENDING VISUAL STUDIO
CHAPTER 51: THE AUTOMATION MODEL
909
Visual Studio Extensibility Options
The Visual Studio Automation Model
909
910
An Overview of the Automation Model
Solutions and Projects
Windows and Documents
Commands
Debugger
Events
910
912
912
914
915
916
Summary
916
CHAPTER 52: ADD-INS
917
Developing an Add-in
917
The Add-in Wizard
917
xxxiv
www.it-ebooks.info
CONTENTS
Project Structure
Testing Your Add-in
The .AddIn File
The Connect Class
Creating a Tool Window
Accessing the Visual Studio Automation Model
Handling Visual Studio Events
Deploying Add-ins
Summary
920
920
922
923
923
926
927
930
930
CHAPTER 53: MANAGED EXTENSIBILITY FRAMEWORK (MEF)
Getting Started with MEF
931
932
Imports and Exports
Contracts
Catalogs
Advanced MEF
933
935
936
937
The Visual Studio Editor
938
The Text Model Subsystem
The Text View Subsystem
The Classification Subsystem
The Operations Subsystem
Extending the Editor
938
938
939
939
939
Editor Extension Points
Editor Services
The Check Comment Highlighter Extension
Summary
941
944
944
950
PART XII: VISUAL STUDIO ULTIMATE
CHAPTER 54: VISUAL STUDIO ULTIMATE FOR ARCHITECTS
Modeling Projects
953
953
UML Diagrams
UML Model Explorer
Using Layer Diagrams to Verify Application Architecture
Linking to Team Foundation Server
Exploring Code
954
958
958
960
960
The Architecture Explorer
Dependency Graphs
Generate Sequence Diagram
Summary
960
962
962
964
xxxv
www.it-ebooks.info
CONTENTS
CHAPTER 55: VISUAL STUDIO ULTIMATE FOR DEVELOPERS
Code Metrics
965
965
Lines of Code
Depth of Inheritance
Class Coupling
Cyclomatic Complexity
Maintainability Index
Excluded Code
966
967
967
967
967
967
Managed Code Analysis Tool
C/C++ Code Analysis Tool
Profiling Tools
Configuring Profiler Sessions
Reports
Standalone Profiler
IntelliTrace
Database Tools
968
969
969
970
971
972
973
974
Database Schemas
SQL-CLR Support
Database Refactoring
Schema Compare
Static Analysis
Transact-SQL Editor
Best Practices
974
976
978
979
980
980
981
Summary
981
CHAPTER 56: VISUAL STUDIO ULTIMATE FOR TESTERS
Automated Tests
983
983
Web Performance Tests
Load Tests
Coded UI Test
Generic Tests
Ordered Test
984
987
988
989
989
Relating Code and Tests
989
Code Coverage
990
Visual Studio Test Management
Microsoft Test Manager
Testing Center
Lab Center
992
992
993
995
Summary
996
xxxvi
www.it-ebooks.info
CONTENTS
CHAPTER 57: TEAM FOUNDATION SERVER
997
Team Project
Process Templates
Work Item Tracking
998
998
1001
Work Item Queries
Work Item Types
Adding Work Items
Work Item State
1001
1003
1003
1003
Excel and Project Integration
Excel
Project
1004
1004
1005
Version Control
1005
Working from Solution Explorer
Check Out
Check In
Resolve Conflicts
Working Offline
Label
History
Annotate
Shelve
Branch
Merge
Team Foundation Build
Reporting and Business Intelligence
Team Portal
Documents
Process Guidance
SharePoint Lists
Dashboards
1006
1007
1007
1008
1009
1010
1011
1012
1013
1013
1014
1015
1017
1018
1018
1018
1019
1019
Web Access
Summary
1020
1020
INDEX
1021
xxxvii
www.it-ebooks.info
www.it-ebooks.info
INTRODUCTION
THROUGHOUT ITS HISTORY, Visual Studio has incorporated the latest advances in Microsoft’s premier
programming languages (Visual Basic and C#) and this version is no different. But alongside support for
language features, is also continuing support for developers. In theory, it is possible to create any .NET
application using tools as simple as Notepad and a command-line window. But the typical developer
would never think to do so. The tools and utilities that come with Visual Studio do more to increase the
productivity of developers than any other single piece of software currently available. Visual Studio 2012 is
no different from previous versions in this respect. It includes a host of improvements and new features that
are aimed at making the life of a developer easier.
Visual Studio 2012 is an enormous product no matter which way you look at it. It can be intimidating to
newcomers and difficult for even experienced .NET developers to fi nd what they need. And that’s where this
book comes in. Professional Visual Studio 2012 looks at every major aspect of this developer tool, showing
you how to harness each feature and offering advice about how best to utilize the various components
effectively. It shows you the building blocks that make up Visual Studio 2012, breaking the user interface
down into manageable chunks for you to understand. It then expands on each of these components with
additional details about exactly how they work both in isolation and in conjunction with other parts of
Visual Studio 2012, along with tools that are not included in the out-of-the-box product, to make your
development efforts even more efficient.
WHO THIS BOOK IS FOR
Professional Visual Studio 2012 is for developers who are new to Visual Studio as well as those
programmers who have some experience but want to learn about features they may have previously
overlooked.
Even if you are familiar with the way previous versions of Visual Studio worked, you may want to at least
skim over Part I. These chapters deal with the basic constructs that make up the user interface. In the past,
the basic interface didn’t change much from version to version. But as soon as you launch Visual Studio
2012 for the fi rst time, you’ll notice that the user interface has gone through some significant changes. While
you can get by without Part I, some of the changes in Visual Studio 2012 can make you a more efficient
developer. And, after all, that’s what you’re looking to get out of this book.
If you’re just starting out, you’ll greatly benefit from the fi rst part, where basic concepts are explained and
you’re introduced to the user interface and how to customize it to suit your own style.
WHAT THIS BOOK COVERS
Microsoft Visual Studio 2012 is arguably the most advanced integrated development environment (IDE)
available for programmers today. It is based on a long history of programming languages and interfaces and
has been influenced by many different variations on the theme of development environments.
With Visual Studio 2012, Microsoft took a chance (and received some pushback) for its decision to revamp
the user interface. Existing developers will fi nd it off-putting at fi rst (although you do get used to it quickly
and will rarely miss what is no longer visible by default). But newcomers to Visual Studio will fi nd it much
easier to work with. This book covers the breadth of Visual Studio 2012. Along the way, you will become
more familiar and comfortable with the new interface.
www.it-ebooks.info
INTRODUCTION
Visual Studio 2012 comes in several versions: Express, Professional, Premium, and Ultimate. The majority
of this book deals with the Professional Edition of Visual Studio 2012, but some parts utilize features found
only in the Premium and Ultimate editions. If you haven’t used these editions before, read through Chapters
54 to 57 for an overview of the features they offer over and above the Professional Edition.
HOW THIS BOOK IS STRUCTURED
This book’s fi rst section is dedicated to familiarizing you with the core aspects of Visual Studio 2012.
Everything you need is contained in the fi rst five chapters, from the IDE structure and layout to the various
options and settings you can change to make the user interface synchronize with your own way of doing
things.
From there, the remainder of the book is broken into 11 parts:
➤
Getting Started: In this part, you learn how to take control of your projects and how to organize them
in ways that work with your own style.
➤
Digging Deeper: Though the many graphical components of Visual Studio that make a programmer’s
job easier are discussed in many places throughout this book, you often need help when you’re in the
process of actually writing code. This part deals with features that support the coding of applications
such as IntelliSense, code refactoring, and creating and running unit tests The .NET Framework
supports dynamic languages and strengthens feature parity between the two primary .NET languages,
C# and VB. This part covers these languages, as well as looking at a range of features that will help
you write better and more consistent code.
➤
Rich Client Applications and Web Applications: For support with building everything from Office
add-ins to cloud applications, Visual Studio enables you to develop applications for a wide range of
platforms. These two parts cover the application platforms that are supported within Visual Studio
2012, including ASP.NET and Office, WPF, Silverlight 5, and ASP.NET MVC. Also, Chapter 20 takes
a look into the support provided for the new Windows Store applications.
➤
Data: A large proportion of applications use some form of data storage. Visual Studio 2012 and the
.NET Framework include strong support for working with databases and other data sources. This
part examines how to use DataSets, the Visual Database Tools, LINQ, Synchronization Services, and
ADO.NET Entity Framework to build applications that work with data. It also shows you how you
can then present this data using Reporting.
➤
Application Services: Through the course of building an application, you are likely to require access to
services that may or may not reside within your organization. This part covers core technologies such
as WCF, WF, Synchronization Services, and WCF RIA services that you can use to connect to these
services.
➤
Configuration and Resources: The built-in support for configuration fi les allows you to adjust the way
an application functions on the fly without having to rebuild it. Furthermore, resource fi les can be
used to both access static data and easily localize an application into foreign languages and cultures.
This part of the book shows how to use .NET configuration and resource fi les.
➤
Debugging: Application debugging is one of the more challenging tasks developers have to tackle, but
correct use of the Visual Studio 2012 debugging features will help you analyze the state of the application and determine the cause of any bugs. This part examines the debugging support provided by the
IDE.
➤
Build and Deployment: In addition to discussing how to build your solutions effectively and getting
applications into the hands of your end users, this part also deals with the process of upgrading your
projects from previous versions.
xl
www.it-ebooks.info
INTRODUCTION
➤
Customizing and Extending Visual Studio: If the functionality found in the previous part isn’t enough
to help you in your coding efforts, Visual Studio 2012 is even more extensible. This part covers the
automation model, how to write add-ins, and then how to use the Microsoft Extensibility Framework
(MEF) to extend Visual Studio 2012.
➤
Visual Studio Ultimate: The fi nal part of the book examines the additional features only available in
the Premium and Ultimate versions of Visual Studio 2012. In addition, you’ll also learn how the Team
Foundation Server provides an essential tool for managing software projects.
Though this breakdown of the Visual Studio feature set provides the most logical and easily understood set
of topics, you may need to look for specific functions that will aid you in a particular activity. To address
this need, references to appropriate chapters are provided whenever a feature is covered in more detail
elsewhere in the book.
WHAT YOU NEED TO USE THIS BOOK
To use this book effectively, you’ll need only one additional item — Microsoft Visual Studio 2012
Professional Edition. With this software installed and the information found in this book, you’ll be able to
get a handle on how to use Visual Studio 2012 effectively in a very short period of time.
This book assumes that you are familiar with the traditional programming model, and it uses both the C#
and Visual Basic (VB) languages to illustrate features within Visual Studio 2012. In addition, it is assumed
that you can understand the code listings without an explanation of basic programming concepts in either
language. If you’re new to programming and want to learn Visual Basic, please take a look at Beginning
Visual Basic 2012 by Bryan Newsome. Similarly, if you are after a great book on C#, track down Beginning
Visual C# 2012, written collaboratively by a host of authors.
Some chapters discuss additional products and tools that work in conjunction with Visual Studio. The following are all available to download either on a trial basi