Tải bản đầy đủ (.pdf) (1,108 trang)

professional visual studio 2012

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (45.73 MB, 1,108 trang )

www.it-ebooks.info
ffirs.indd iffirs.indd i 10/18/2012 6:16:02 PM10/18/2012 6:16:02 PM
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-Specifi c Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
 PART IV RICH CLIENT APPLICATIONS
CHAPTER 17 Windows Forms Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
CHAPTER 18 Windows Presentation Foundation (WPF) . . . . . . . . . . . . . . . . . . . . . . . . 305
CHAPTER 19 O ce Business Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
CHAPTER 20 Windows Store Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Continues
ffirs.indd iffirs.indd i 10/18/2012 6:16:02 PM10/18/2012 6:16:02 PM


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 Workfl ow 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 Confi guration 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

ffirs.indd iiffirs.indd ii 10/18/2012 6:16:03 PM10/18/2012 6:16:03 PM
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
ffirs.indd iiiffirs.indd iii 10/18/2012 6:16:03 PM10/18/2012 6:16:03 PM
www.it-ebooks.info
ffirs.indd ivffirs.indd iv 10/18/2012 6:16:03 PM10/18/2012 6:16:03 PM
www.it-ebooks.info
PROFESSIONAL
Visual Studio® 2012
Bruce Johnson
ffirs.indd vffirs.indd v 10/18/2012 6:16:03 PM10/18/2012 6:16:03 PM
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 />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 speci cally disclaim all warranties, including
without limitation warranties of  tness for a particular purpose. No warranty may be created or extended by sales or pro-
motional 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 pub-
lisher 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 stan-
dard 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
. 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 af liates, in the United States and other coun-
tries, 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.
ffirs.indd viffirs.indd vi 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
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.
— B J
ffirs.indd viiffirs.indd vii 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
www.it-ebooks.info
ACQUISITIONS EDITOR
Mary James
PROJECT EDITOR
Kelly Talbot
TECHNICAL EDITORS
Joe Bennett
Andrew Moore
PRODUCTION EDITOR

Christine Mugnolo
COPY EDITOR
San Dee Phillips
EDITORIAL MANAGER
Mary Beth Wakefi eld
FREELANCER EDITORIAL MANAGER
Rosemarie Graham
ASSOCIATE DIRECTOR OF MARKETING
David Mayhew
MARKETING MANAGER
Ashley Zurcher
BUSINESS MANAGER
Amy Knies
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Neil Edde
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Katie Crocker
PROOFREADERS
Jennifer Bennett, Word One New York
Scott Klemp, Word One New York
James Saturnio, Word One New York
INDEXER
Johnna VanHoose Dinse

COVER DESIGNER
LeAndra Young
COVER IMAGE
© Eric Delmar / iStockPhoto
CREDITS
ffirs.indd viiiffirs.indd viii 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
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  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 technol-
ogy, 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 Certi ed 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
(
has decreased recently, the activity on his
Twitter account ( 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.
ffirs.indd ixffirs.indd ix 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
www.it-ebooks.info
ffirs.indd xffirs.indd x 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
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 pal-
pable). But I can also tell you that without the rarely acknowledged efforts of the others involved in the edi-

torial 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 writ-
ing in the passive voice and  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.
— B J
ffirs.indd xiffirs.indd xi 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
www.it-ebooks.info
ffirs.indd xiiffirs.indd xii 10/18/2012 6:16:04 PM10/18/2012 6:16:04 PM
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 3
Running Visual Studio 2012 4
The Visual Studio IDE 5
Developing, Building, Debugging, and Deploying
Your First Application 7
Summary 12
CHAPTER 2: THE SOLUTION EXPLORER, TOOLBOX, AND PROPERTIES 13
The Solution Explorer 13

Previewing Files 15
Common Tasks 16
The Toolbox 21
Arranging Components 23
Adding Components 24
Properties 25
Extending the Properties Window 27
Summary 30
CHAPTER 3: OPTIONS AND CUSTOMIZATIONS 31
The Start Page 31
Customizing the Start Page 32
Window Layout 32
Viewing Windows and Toolbars 33
Navigating Open Items 33
Docking 34
The Editor Space 37
Fonts and Colors 38
Visual Guides 38
Full-Screen Mode 40
Tracking Changes 40
ftoc.indd xiiiftoc.indd xiii 10/18/2012 6:16:49 PM10/18/2012 6:16:49 PM
www.it-ebooks.info
xiv
CONTENTS
Other Options 41
Keyboard Shortcuts 41
Quick Launch 42
Projects and Solutions 43
Build and Run 44
VB Options 45

Importing and Exporting Settings 45
Summary 47
CHAPTER 4: THE VISUAL STUDIO WORKSPACE 49
The Code Editor 49
The Code Editor Window Layout 49
Regions 50
Outlining 51
Code Formatting 51
Navigating Forward/Backward 53
Additional Code Editor Features 53
Split View 53
Tear Away (Floating) Code Windows 54
Duplicating Solution Explorer 55
Creating Tab Groups 56
Advanced Functionality 56
The Command Window 58
The Immediate Window 59
The Class View 59
The Error List 60
The Object Browser 61
The Code Defi nition Window 61
The Call Hierarchy Window 62
The Document Outline Tool Window 63
HTML Outlining 63
Control Outlining 64
Reorganizing Tool Windows 66
Summary 66
CHAPTER 5: FIND AND REPLACE AND HELP 67
Quick Find/Replace 67
Quick Find 68

Quick Replace 69
Find Options 69
ftoc.indd xivftoc.indd xiv 10/18/2012 6:16:49 PM10/18/2012 6:16:49 PM
www.it-ebooks.info
xv
CONTENTS
Find and Replace Options 70
Find/Replace in Files 70
Find in Files 70
Find Dialog Options 71
Regular Expressions 72
Results Window 73
Replace in Files 74
Navigate To 74
Accessing Help 75
Navigating and Searching the Help System 76
Confi guring the Help System 77
Summary 77
PART II: GETTING STARTED
CHAPTER 6: SOLUTIONS, PROJECTS, AND ITEMS 81
Solution Structure 81
Solution File Format 83
Solution Properties 83
Common Properties 84
Confi guration Properties 85
Project Types 86
Project Files Format 88
Project Properties 88
Application 89
Compile (Visual Basic Only) 92

Build (C# and F# Only) 93
Build Events (C# and F# Only) 94
Debug 94
References (Visual Basic Only) 96
Resources 97
Services 97
Settings 98
Reference Paths (C# and F# Only) 99
Signing 100
My Extensions (Visual Basic Only) 100
Security 101
Publish 102
Code Analysis 102
ftoc.indd xvftoc.indd xv 10/18/2012 6:16:49 PM10/18/2012 6:16:49 PM
www.it-ebooks.info
xvi
CONTENTS
Web Application Project Properties 103
Web 103
Silverlight Applications 104
Package/Publish Web 105
Package/Publish SQL 106
Web Site Projects 107
Summary 107
CHAPTER 7: INTELLISENSE AND BOOKMARKS 109
IntelliSense Explained 109
General IntelliSense 110
IntelliSense and C++ 111
Completing Words and Phrases 111
Parameter Information 116

Quick Info 117
JavaScript IntelliSense 117
The JavaScript IntelliSense Context 118
Referencing Another JavaScript File 118
IntelliSense Options 119
General Options 119
Statement Completion 121
C#-Specifi c Options 121
Extended IntelliSense 122
Code Snippets 122
XML Comments 123
Adding Your Own IntelliSense 123
Bookmarks and the Bookmark Window 123
Summary 125
CHAPTER 8: CODE SNIPPETS AND REFACTORING 127
Code Snippets Revealed 128
Storing Code Blocks in the Toolbox 128
Code Snippets 129
Using Snippets in C# 129
Using Snippets in VB 130
Surround With Snippet 131
Code Snippets Manager 132
Creating Snippets 133
Reviewing Existing Snippets 133
Accessing Refactoring Support 136
ftoc.indd xviftoc.indd xvi 10/18/2012 6:16:49 PM10/18/2012 6:16:49 PM
www.it-ebooks.info
xvii
CONTENTS
Refactoring Actions 137

Extract Method 137
Encapsulate Field 140
Extract Interface 140
Reorder Parameters 143
Remove Parameters 143
Rename 144
Generate Method Stub 145
Organize Usings 145
Summary 146
CHAPTER 9: SERVER EXPLORER 147
Server Connections 147
Event Logs 148
Management Classes 150
Management Events 152
Message Queues 154
Performance Counters 156
Services 159
Data Connections 160
SharePoint Connections 160
Summary 161
CHAPTER 10: MODELING WITH THE CLASS DESIGNER 163
Creating a Class Diagram 163
The Design Surface 164
The Toolbox 165
Entities 165
Connectors 166
The Class Details 166
The Properties Window 167
Layout 168
Exporting Diagrams 168

Code Generation and Refactoring 169
Drag-and-Drop Code Generation 169
IntelliSense Code Generation 171
Refactoring with the Class Designer 171
Modeling Power Toys for Visual Studio 172
Visualization Enhancements 172
Functionality Enhancements 173
Summary 174
ftoc.indd xviiftoc.indd xvii 10/18/2012 6:16:49 PM10/18/2012 6:16:49 PM
www.it-ebooks.info
xviii
CONTENTS
PART III: DIGGING DEEPER
CHAPTER 11: UNIT TESTING 177
Your First Test Case 177
Identifying Tests Using Attributes 183
Additional Test Attributes 183
Asserting the Facts 185
The Assert Class 185
The StringAssert Class 186
The CollectionAssert Class 186
The ExpectedException Attribute 186
Initializing and Cleaning Up 188
TestInitialize and TestCleanup 188
ClassInitialize and ClassCleanup 188
AssemblyInitialize and AssemblyCleanup 188
Testing Context 189
Data 189
Writing Test Output 191
Advanced Unit Testing 192

Custom Properties 192
Testing Private Members 193
Testing Code Contracts 194
Summary 196
CHAPTER 12: DOCUMENTATION WITH XML COMMENTS 197
Inline Commenting 197
XML Comments 198
Adding XML Comments 198
XML Comment Tags 199
Using XML Comments 211
IntelliSense Information 212
Generating Documentation with GhostDoc 212
Compiling Documentation with Sandcastle 214
Task List Comments 216
Summary 218
CHAPTER 13: CODE CONSISTENCY TOOLS 219
Source Control 219
Selecting a Source Control Repository 220
Accessing Source Control 222
ftoc.indd xviiiftoc.indd xviii 10/18/2012 6:16:50 PM10/18/2012 6:16:50 PM
www.it-ebooks.info
xix
CONTENTS
Coding Standards 226
Code Analysis with FxCop 226
Style Using StyleCop 229
Code Contracts 230
Summary 232
CHAPTER 14: CODE GENERATION WITH T4 233
Creating a T4 Template 233

T4 Building Blocks 236
Expression Blocks 237
Statement Blocks 237
Class Feature Blocks 239
How T4 Works 240
T4 Directives 242
Template Directive 242
Output Directive 243
Assembly Directive 243
Import Directive 243
Include Directive 244
Troubleshooting 245
Design-Time Errors 245
Compiling Transformation Errors 245
Executing Transformation Errors 246
Generated Code Errors 246
Generating Code Assets 246
Runtime Text Templates 250
Using Runtime Text Templates 251
Di erences Between Runtime Text Templates and Standard T4 Templates 253
Tips and Tricks 254
Summary 255
CHAPTER 15: PROJECT AND ITEM TEMPLATES 257
Creating Templates 257
Item Template 257
Project Template 261
Template Structure 262
Template Parameters 263
Template Locations 265
Extending Templates 265

Template Project Setup 265
ftoc.indd xixftoc.indd xix 10/18/2012 6:16:50 PM10/18/2012 6:16:50 PM
www.it-ebooks.info
xx
CONTENTS
IWizard 266
Generating the Extended Project Template 271
Starter Kits 272
Online Templates 273
Summary 273
CHAPTER 16: LANGUAGESPECIFIC FEATURES 275
Hitting a Nail with the Right Hammer 275
Imperative 276
Declarative 276
Dynamic 276
Functional 277
What’s It All Mean? 277
A Tale of Two Languages 278
The Async Keyword 278
Caller Information 280
Visual Basic 281
Iterators 281
The Global Keyword 281
Visual Basic PowerPacks 282
F# 283
Your First F# Program 283
Exploring F# Language Features 285
Type Providers 287
Query Expressions 287
Auto-Implemented Properties 288

Summary 288
PART IV: RICH CLIENT APPLICATIONS
CHAPTER 17: WINDOWS FORMS APPLICATIONS 291
Getting Started 291
The Windows Form 292
Appearance Properties 293
Layout Properties 293
Window Style Properties 293
Form Design Preferences 294
Adding and Positioning Controls 296
Vertically Aligning Text Controls 297
Automatic Positioning of Multiple Controls 297
ftoc.indd xxftoc.indd xx 10/18/2012 6:16:50 PM10/18/2012 6:16:50 PM
www.it-ebooks.info
xxi
CONTENTS
Tab Order and Layering Controls 298
Locking Control Design 299
Setting Control Properties 299
Service-Based Components 300
Smart Tag Tasks 301
Container Controls 301
Panel and SplitContainer 301
FlowLayoutPanel 302
TableLayoutPanel 303
Docking and Anchoring Controls 303
Summary 304
CHAPTER 18: WINDOWS PRESENTATION FOUNDATION WPF 305
What Is WPF? 305
Getting Started with WPF 307

XAML Fundamentals 309
The WPF Controls 310
The WPF Layout Controls 311
The WPF Designer and XAML Editor 313
Working with the XAML Editor 314
Working with the WPF Designer 315
The Properties Tool Window 317
Data Binding Features 321
Styling Your Application 324
Windows Forms Interoperability 325
Hosting a WPF Control in Windows Forms 326
Hosting a Windows Forms Control in WPF 327
Debugging with the WPF Visualizer 328
Summary 330
CHAPTER 19: OFFICE BUSINESS APPLICATIONS 331
Choosing an O ce Project Type 331
Document-Level Customizations 332
Application-Level Add-ins 333
Creating a Document-Level Customization 333
Your First VSTO Project 333
Protecting the Document Design 336
Adding an Actions Pane 337
Creating an Application Add-in 338
Some Outlook Concepts 338
ftoc.indd xxiftoc.indd xxi 10/18/2012 6:16:50 PM10/18/2012 6:16:50 PM
www.it-ebooks.info
xxii
CONTENTS
Creating an Outlook Form Region 339
Debugging O ce Applications 343

Unregistering an Add-in 343
Disabled Add-ins 344
Deploying O ce Applications 345
Summary 346
CHAPTER 20: WINDOWS STORE APPLICATIONS 347
What Is a Windows Store Application? 347
Content Before Chrome 348
Snap and Scale 349
Semantic Zoom 349
Contracts 349
Tiles 350
Embrace the Cloud 350
Creating a Windows Store Application 350
The Windows 8 Simulator 353
Your Windows Store Application 355
Summary 358
PART V: WEB APPLICATIONS
CHAPTER 21: ASP.NET WEB FORMS 361
Web Application Versus Web Site Projects 362
Creating Web Projects 362
Creating a Web Site Project 363
Creating a Web Application Project 366
Other Web Projects 367
Starter Kits, Community Projects, and Open-Source Applications 368
Designing Web Forms 368
The HTML Designer 368
Positioning Controls and HTML Elements 370
Formatting Controls and HTML Elements 372
CSS Tools 372
Validation Tools 376

Web Controls 377
Navigation Components 377
User Authentication 378
Data Components 379
Web Parts 382
ftoc.indd xxiiftoc.indd xxii 10/18/2012 6:16:50 PM10/18/2012 6:16:50 PM
www.it-ebooks.info
xxiii
CONTENTS
Master Pages 383
Rich Client-Side Development 385
Developing with JavaScript 385
Working with ASP.NET AJAX 386
Using AJAX Control Extenders 388
ASP.NET Web Site Administration 390
Security 391
Application Settings 393
ASP.NET Confi guration in IIS 393
Summary 394
CHAPTER 22: ASP.NET MVC 395
Model View Controller 396
Getting Started with ASP.NET MVC 396
Choosing a Model 398
Controllers and Action Methods 399
MVC Sca olding 399
Rendering a UI with Views 402
Advanced MVC 409
Routing 409
Action Method Parameters 412
Areas 415

Validation 417
Partial Views 419
Dynamic Data Templates 419
jQuery 422
Summary 424
CHAPTER 23: SILVERLIGHT 425
What Is Silverlight? 425
Getting Started with Silverlight 426
Navigation Framework 432
Theming 433
Enabling Running Out of Browser 435
Summary 438
CHAPTER 24: DYNAMIC DATA 439
Creating a Dynamic Data Web Application 440
Adding a Data Model 441
Exploring a Dynamic Data Application 443
ftoc.indd xxiiiftoc.indd xxiii 10/18/2012 6:16:50 PM10/18/2012 6:16:50 PM
www.it-ebooks.info

×