30

PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started
Page 2: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started
Page 3: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ffi rs.indd 08/06/2015 Page i

PROFESSIONAL

Visual Studio® 2015

Bruce Johnson

Page 4: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ffi rs.indd 08/06/2015 Page ii

Professional Visual Studio® 2015

Published byJohn Wiley & Sons, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com

Copyright © 2015 by John Wiley & Sons, Inc., Indianapolis, Indiana

Published simultaneously in Canada

ISBN: 978-1-119-06805-1ISBN: 978-1-119-06791-7 (ebk)ISBN: 978-1-119-06787-0 (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 specifi cally disclaim all warranties, including without limitation warranties of fi tness 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, read ers 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 http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number: 2015942780

Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trade-marks 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. 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.

Page 5: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ffi rs.indd 08/06/2015 Page iii

I’d like to thank my wife, Ali, and my four children,

Kyle, Cameron, Gillian, and Curtis, for their love and

support. All the kids are teenagers now, so they were

quite happy to leave me alone to write as much as I

needed. Unless they needed a ride somewhere, that is.

But they are my loves and my life would be much less

rich without them.

Page 6: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started
Page 7: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ffi rs.indd 08/06/2015 Page v

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 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 rich 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 Certifi ed Trainer (MCT) and is the 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 ten years.

ABOUT THE TECHNICAL EDITOR

GEORGE EVJEN is the Executive Vice President of Operations for Six0Run, a cloud-based collegiate recruiting and athletics management software application. George also serves as the Director of Development for ArchitectNow, a St. Louis–based consulting company specializing in custom client application architecture, design, and development, with clients ranging from small technology start-ups to global enterprises. Prior to his involvement in the software industry, George spent more than a dozen years coaching men’s basketball at all levels of the collegiate ranks. You can fi nd out more about George and ArchitectNow’s capabilities at http://www.architectnow.net.

Page 8: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started
Page 9: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ffi rs.indd 08/06/2015 Page vii

ACQUISITIONS EDITORKenyon Brown

PROJECT EDITORKelly Talbot

TECHNICAL EDITORGeorge Evjen

PRODUCTION EDITORSaleem Hameed Sulthan

COPY EDITORGill Editorial Services

MANAGER OF CONTENT DEVELOPMENT & ASSEMBLYMary Beth Wakefi eld

PRODUCTION MANAGERKathleen Wisor

MARKETING DIRECTORDavid Mayhew

MARKETING MANAGERCarrie Sherrill

PROFESSIONAL TECHNOLOGY & STRATEGY DIRECTORBarry Pruett

BUSINESS MANAGERAmy Knies

ASSOCIATE PUBLISHERJim Minatel

PROJECT COORDINATOR, COVERBrent Savage

PROOFREADERNancy Bell

INDEXERNancy Guenther

COVER DESIGNERWiley

COVER IMAGE©Getty Images/Joyoyo Chen

CREDITS

Page 10: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started
Page 11: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ffi rs.indd 08/06/2015 Page ix

ACKNOWLEDGMENTS

TO THE OUTSIDE, IT might look like the writing of a book is an individual effort. It’s not. Not even close. There is no way that this book could have come to fruition without the efforts and assistance of a number of people. And, as true as that is, the others who are part of the writing and editorial process never get enough of the credit. The fact that the book is clear, accurate, and useful is because of the contribution of my editor, technical editor, and copy editor. And the people who do the production work. And the cover. And any other part of the book that I have forgotten to mention. I’m grateful for the help and have enjoyed working with such talented people.

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 impres-sive. I suspect he was forced to work with me again, but I can’t tell for sure. Thanks also go to George Evjen, who did a fantastic job making sure that the technical mistakes I made in my fi rst draft were cleaned up before publication. Finally, thanks to Karen Gill, who had to read what I wrote before it had been made grammatically correct. The efforts of all of these individuals are what make the book possible and, hopefully, a success.

Page 12: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started
Page 13: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

ftoc.indd 08/08/2015 Page xi

CONTENTS

INTRODUCTION xxxix

PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1

CHAPTER 1: A QUICK TOUR 3

Getting Started 3Installing Visual Studio 2015 3Running Visual Studio 2015 6Is Visual Studio Really Cloud Enabled? 7

The Visual Studio IDE 10Developing, Building, Debugging, and Deploying Your First Application 12

Summary 17

CHAPTER 2: THE SOLUTION EXPLORER, TOOLBOX, AND PROPERTIES 19

The Solution Explorer 20Previewing Files 22Common Tasks 23

Adding Projects and Items 25Adding References 28Adding Service References 29Adding Connected Services 30Adding Analyzers 31Adding NuGet Packages 32

The Toolbox 35Arranging Components 37Adding Components 38

Properties 40Extending the Properties Window 42

The Browsable Attribute 42DisplayName Attribute 43Description 43Category 43DefaultValue 44AmbientValue 44

Summary 46

Page 14: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xii

CONTENTS

ftoc.indd 08/08/2015 Page xii

CHAPTER 3: OPTIONS AND CUSTOMIZATIONS 47

The Start Page 48Customizing the Start Page 49

Window Layout 49Viewing Windows and Toolbars 50Docking 50Saving the Window Layout 53

The Editor Space 55Navigating Open Items 57Fonts and Colors 58Visual Guides 59Full-Screen Mode 60Tracking Changes 61

Other Options 62Keyboard Shortcuts 62Quick Launch 63Projects and Solutions 65Build and Run 66VB Options 67

Importing and Exporting Settings 67Synchronized Settings 70

Summary 71

CHAPTER 4: THE VISUAL STUDIO WORKSPACE 73

The Code Editor 73The Code Editor Window Layout 74Regions 75Outlining 75Code Formatting 76Navigating Forward/Backward 78Additional Code Editor Features 78

Reference Highlighting 78Code Zooming 78Word Wrap 79Line Numbers 79Auto Brace Complete 80

Split View 80Tear Away (Floating) Code Windows 81Duplicating Solution Explorer 82

Page 15: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xiii

CONTENTS

ftoc.indd 08/08/2015 Page xiii

Creating Tab Groups 82Advanced Functionality 84

Commenting/Uncommenting a Code Block 84Block Selection 84Multiline Editing 84The Clipboard Ring 85Full-Screen View 85Go to Defi nition 85Find All References 85

Code Navigation 86Peek Defi nition 86Enhanced Scrollbar 87Navigate To 89

The Command Window 91The Immediate Window 92The Class View 93The Error List 94The Object Browser 95The Document Outline Tool Window 96

HTML Outlining 97Control Outlining 98

Reorganizing Tool Windows 100Summary 101

CHAPTER 5: FIND AND REPLACE AND HELP 103

Quick Find/Replace 104Quick Find 104Quick Replace 105Find Options 106Find and Replace Options 106

Find/Replace in Files 106Find in Files 107Find Dialog Options 108Regular Expressions 109Results Window 111Replace in Files 111

Accessing Help 112Navigating and Searching the Help System 114Confi guring the Help System 114

Summary 115

Page 16: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xiv

CONTENTS

ftoc.indd 08/08/2015 Page xiv

PART II: GETTING STARTED 117

CHAPTER 6: SOLUTIONS, PROJECTS, AND ITEMS 119

Solution Structure 120Solution File Format 121Solution Properties 122

Common Properties 123Confi guration Properties 124

Project Types 126Project Files Format 128Project Properties 129

Application 130Assembly Information 130User Account Control Settings 131Application Framework (Visual Basic Only) 132

Compile (Visual Basic Only) 133Build (C# and F# Only) 135Build Events (C# and F# Only) 136Debug 137

Start Action 137Start Options 137Enable Debuggers 137

References (Visual Basic Only) 138Resources 139Services 140Settings 141Reference Paths (C# and F# Only) 142Signing 143My Extensions (Visual Basic Only) 144Security 144Publish 145Code Analysis 146

Web Application Project Properties 147Web 148Silverlight Applications 148Package/Publish Web 149Package/Publish SQL 150

Web Site Projects 151NuGet Packages 152

NuGet Package Manager 152Package Manager Console 154

Summary 154

Page 17: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xv

CONTENTS

ftoc.indd 08/08/2015 Page xv

CHAPTER 7: INTELLISENSE AND BOOKMARKS 155

IntelliSense Explained 155General IntelliSense 156IntelliSense and C++ 158Completing Words and Phrases 158

In Context 159List Members 160Suggestion Mode 160Stub Completion 161Generate From Usage 163

Parameter Information 165Quick Info 166

JavaScript IntelliSense 166The JavaScript IntelliSense Context 167Referencing Another JavaScript File 167

XAML IntelliSense 168IntelliSense Options 169

General Options 169Statement Completion 171C#-Specifi c Options 171

Extended IntelliSense 172Code Snippets 173XML Comments 173Adding Your Own IntelliSense 173

Bookmarks and the Bookmark Window 173Summary 176

CHAPTER 8: CODE SNIPPETS AND REFACTORING 177

Code Snippets Revealed 178Storing Code Blocks in the Toolbox 178Code Snippets 179Using Snippets in C# 179Using Snippets in VB 181Surround With Snippet 182Code Snippets Manager 183Creating Snippets 184Reviewing Existing Snippets 184Distributing Code Snippets 188

Accessing Refactoring Support 189Refactoring Actions 189

Page 18: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xvi

CONTENTS

ftoc.indd 08/08/2015 Page xvi

Extract Method 190Encapsulate Field 191Extract Interface 192Change Signature 193Inline and Explaining Variables 194Rename 195Generate Method Stub 195Organize Usings 196

Summary 197

CHAPTER 9: SERVER EXPLORER 199

Server Connections 200Event Logs 201Management Classes 204Management Events 206Message Queues 210Performance Counters 213Services 217

Data Connections 218SharePoint Connections 219Summary 220

CHAPTER 10: MODELING WITH THE CLASS DESIGNER 221

Creating a Class Diagram 222The Design Surface 223The Toolbox 224

Entities 224Connectors 225

The Class Details 226The Properties Window 227Layout 228Exporting Diagrams 229Code Generation and Refactoring 229

Drag-and-Drop Code Generation 229IntelliSense Code Generation 232Refactoring with the Class Designer 232

Summary 233

Page 19: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xvii

CONTENTS

ftoc.indd 08/08/2015 Page xvii

PART III: DIGGING DEEPER 235

CHAPTER 11: UNIT TESTING 237

Your First Test Case 238Identifying Tests Using Attributes 243

TestClass 243TestMethod 244

Additional Test Attributes 244Description 244Owner 244Priority 244TestCategories 244WorkItems 245Ignore 245Timeout 245

Unit Tests and Code Lens 246Asserting the Facts 248

The Assert Class 248The StringAssert Class 249The CollectionAssert Class 249The ExpectedException Attribute 249

Initializing and Cleaning Up 251TestInitialize and TestCleanup 251ClassInitialize and ClassCleanup 251AssemblyInitialize and AssemblyCleanup 252

Testing Context 252Data 253Writing Test Output 255

Advanced Unit Testing 257Custom Properties 257Testing Private Members 258

IntelliTest 259Summary 262

CHAPTER 12: DOCUMENTATION WITH XML COMMENTS 263

Inline Commenting 264XML Comments 265

Adding XML Comments 265XML Comment Tags 266

Page 20: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xviii

CONTENTS

ftoc.indd 08/08/2015 Page xviii

The <c> Tag 266The <code> Tag 267The <example> Tag 267The <exception> Tag 268The <include> Tag 269The <list> Tag 271The <para> Tag 272The <param> Tag 272The <paramref> Tag 273The <permission> Tag 274The <remarks> Tag 274The <returns> Tag 275The <see> Tag 276The <seealso> Tag 276The <summary> Tag 277The <typeparam> Tag 277The <typeparamref> Tag 278The <value> Tag 279

Using XML Comments 279IntelliSense Information 281

Generating Documentation with GhostDoc 281Compiling Documentation with Sandcastle 282Task List Comments 286Summary 288

CHAPTER 13: CODE CONSISTENCY TOOLS 289

Source Control 289Selecting a Source Control Repository 290

Environment Settings 291Accessing Source Control 291

Adding the Solution 291Solution Explorer 293Changes 293Merging Changes 294History 296

Summary 297

CHAPTER 14: CODE GENERATION WITH T4 299

Creating a T4 Template 300T4 Building Blocks 303

Expression Blocks 304

Page 21: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xix

CONTENTS

ftoc.indd 08/08/2015 Page xix

Statement Blocks 304Class Feature Blocks 306

How T4 Works 307T4 Directives 310

Template Directive 310Output Directive 311Assembly Directive 311Import Directive 312Include Directive 313

Troubleshooting 313Design-Time Errors 314Compiling Transformation Errors 314Executing Transformation Errors 315Generated Code Errors 315

Generating Code Assets 316Runtime Text Templates 319

Using Runtime Text Templates 321Differences between Runtime Text Templates and Standard

T4 Templates 324Tips and Tricks 325Summary 326

CHAPTER 15: PROJECT AND ITEM TEMPLATES 327

Creating Templates 327Item Template 328Project Template 332Template Structure 333Template Parameters 335Template Locations 336

Extending Templates 337Template Project Setup 337IWizard 337Generating the Extended Project Template 342

Starter Kits 343Online Templates 344Summary 345

CHAPTER 16: LANGUAGE-SPECIFIC FEATURES 347

Hitting a Nail with the Right Hammer 348Imperative 348

Page 22: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xx

CONTENTS

ftoc.indd 08/08/2015 Page xx

Declarative 348Dynamic 349Functional 349What’s It All Mean? 350

A Tale of Two Languages 351.NET Compiler Platform (Roslyn) 351

The Compiler API 352The Diagnostic API 353Workspaces API 353

F# 353Your First F# Program 353Exploring F# Language Features 357Type Providers 359Query Expressions 360Auto-Implemented Properties 360

Summary 361

PART IV: RICH CLIENT APPLICATIONS 363

CHAPTER 17: WINDOWS FORMS APPLICATIONS 365

Getting Started 365The Windows Form 366

Appearance Properties 368Layout Properties 369Window Style Properties 369

Form Design Preferences 369Adding and Positioning Controls 371

Vertically Aligning Text Controls 373Automatic Positioning of Multiple Controls 374Tab Order and Layering Controls 375Locking Control Design 376Setting Control Properties 376Service-Based Components 377Smart Tag Tasks 378

Container Controls 379Panel and SplitContainer 379FlowLayoutPanel 380TableLayoutPanel 381

Docking and Anchoring Controls 382Summary 383

Page 23: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxi

CONTENTS

ftoc.indd 08/08/2015 Page xxi

CHAPTER 18: WINDOWS PRESENTATION FOUNDATION (WPF) 385

What Is WPF? 386Getting Started with WPF 387

XAML Fundamentals 389The WPF Controls 390The WPF Layout Controls 392

The WPF Designer and XAML Editor 394Working with the XAML Editor 396Working with the WPF Designer 396The Properties Tool Window 399Data Binding Features 405

Styling Your Application 410Windows Forms Interoperability 413

Hosting a WPF Control in Windows Forms 413Hosting a Windows Forms Control in WPF 415

Debugging with the WPF Visualizer 416Summary 418

CHAPTER 19: OFFICE BUSINESS APPLICATIONS 419

Choosing an Offi ce Project Type 420Document-Level Customizations 421Application-Level Add-Ins 421

Creating a Document-Level Customization 422Your First VSTO Project 422Protecting the Document Design 426Adding an Actions Pane 427

Creating an Application Add-In 429Some Outlook Concepts 429Creating an Outlook Form Region 430

Debugging Offi ce Applications 434Unregistering an Add-In 434Disabled Add-Ins 436

Deploying Offi ce Applications 437Summary 438

CHAPTER 20: WINDOWS STORE APPLICATIONS 439

What Is a Windows Store Application? 440Content before Chrome 441Snap and Scale 441

Page 24: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxii

CONTENTS

ftoc.indd 08/08/2015 Page xxii

Semantic Zoom 441Contracts 442Tiles 442Embracing the Cloud 442

Creating a Windows Store Application 443The Windows 8 Simulator 446

Interaction Mode 447Two-Finger Gestures 447Device Characteristics 447Location 448Screenshots 449Network Simulation 449

Your Windows Store Application 449.NET Native Compilation 451

Compiling Using .NET Native Tools 452Summary 453

CHAPTER 21: WINDOWS PHONE 455

Creating a Windows Phone Project 455Debugging Your Application 458

Using the Windows Phone Emulator 459Deploying to a Real Phone 460

Phone Developer Power Tools 463Application Verifi er 464Performance Monitor 466Performance Recorder 467

Summary 468

CHAPTER 22: UNIVERSAL APPS 469

Portable Class Library 470Shared Projects 474Universal Windows Apps 474Summary 479

PART V: WEB APPLICATIONS 481

CHAPTER 23: ASP.NET WEB FORMS 483

Web Application Versus Web Site Projects 484Creating Web Projects 485

Creating a Web Site Project 485

Page 25: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxiii

CONTENTS

ftoc.indd 08/08/2015 Page xxiii

Creating a Web Application Project 489Designing Web Forms 492

The HTML Designer 492Positioning Controls and HTML Elements 495Formatting Controls and HTML Elements 497CSS Tools 499Validation Tools 503

Web Controls 505Navigation Components 505User Authentication 506Data Components 508

Data Source Controls 508Data View Controls 510Data Helper Controls 511

Web Parts 511Master Pages 512Rich Client-Side Development 514

Developing with JavaScript 514Working with ASP.NET AJAX 516

Summary 518

CHAPTER 24: ASP.NET MVC 519

Model View Controller 520Getting Started with ASP.NET MVC 521Choosing a Model 524Controllers and Action Methods 525

MVC Scaffolding 525Rendering a UI with Views 528Advanced MVC 536

Routing 536Action Method Parameters 540

Model Binders 542Areas 544Validation 546Partial Views 548Dynamic Data Templates 549

Display Templates 549Edit Templates 551

jQuery 552ASP.NET MVC 6 (and ASP.NET 5) 554Summary 558

Page 26: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxiv

CONTENTS

ftoc.indd 08/08/2015 Page xxiv

CHAPTER 25: SILVERLIGHT 559

What Is Silverlight? 560Getting Started with Silverlight 561Navigation Framework 568Theming 569Enabling Running Out of Browser 571Summary 575

CHAPTER 26: SHAREPOINT 577

SharePoint Execution Models 578Farm Solution 578Sandbox Solution 578App Model 579

Preparing the Development Environment 580Exploring SharePoint 2013 581Creating a SharePoint Project 583Building Custom SharePoint Components 587

Developing Web Parts 587Creating Content Types and Lists 588Adding Event Receivers 592Creating SharePoint Workfl ows 593

Working with Features 595Packaging and Deployment 596Summary 599

CHAPTER 27: WINDOWS AZURE 601

The Windows Azure Platform 602The Compute Emulator 604Table, Blob, and Queue Storage 606Application Deployment 610

SQL Azure 613AppFabric 614

Service Bus 615Access Control Service 615

Azure Mobile Services 615Azure Websites 616Azure Virtual Machines 616

Connectivity 617Endpoints 617Virtual Network 617

Summary 618

Page 27: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxv

CONTENTS

ftoc.indd 08/08/2015 Page xxv

PART VI: DATA 619

CHAPTER 28: VISUAL DATABASE TOOLS 621

Database Windows in Visual Studio 2015 622Server Explorer 623

Table Editing 625Relationship Editing 626Views, Stored Procedures, and Functions 627

The Data Sources Window 627SQL Server Object Explorer 628

Editing Data 630Summary 631

CHAPTER 29: DATASETS AND DATABINDING 633

DataSets Overview 634Adding a Data Source 635The DataSet Designer 636

Binding Data 639BindingSource 641BindingNavigator 644Data Source Selections 647Saving Changes 650Inserting New Items 652Validation 653Customized DataSets 655BindingSource Chains and the DataGridView 657

Working with Data Sources 659The Web Service Data Source 661

Summary 663

CHAPTER 30: LANGUAGE INTEGRATED QUERIES (LINQ) 665

LINQ Providers 666Old-School Queries 666Query Pieces 669

From 669Select 670Where 671Group By 671Custom Projections 672Order By 673

Page 28: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxvi

CONTENTS

ftoc.indd 08/08/2015 Page xxvi

Debugging and Execution 674LINQ to XML 675

VB XML Literals 677Creating XML with LINQ 677

Expression Holes 678Querying XML 680Schema Support 681LINQ to SQL 683

Creating the Object Model 683Querying with LINQ to SQL 686

Inserts, Updates, and Deletes 687Stored Procedures 688

Binding LINQ to SQL Objects 691Summary 693

CHAPTER 31: THE ADO.NET ENTITY FRAMEWORK 695

What Is the Entity Framework? 696Comparison with LINQ to SQL 696Entity Framework Concepts 697

Getting Started 697Creating an Entity Model 698

The Entity Data Model Wizard 698The Entity Framework Designer 702Creating/Modifying Entities 706

Changing Property Names 706Adding Properties to an Entity 707Creating Complex Types 708Creating an Entity 708

Creating/Modifying Entity Associations 710Entity Inheritance 711Validating an Entity Model 711Updating an Entity Model with Database Changes 712

Querying the Entity Model 712LINQ to Entities Overview 713Getting an Object Context 713CRUD Operations 714

Data Retrieval 714Saving Data 716

Navigating Entity Associations 718Advanced Functionality 719

Updating a Database from an Entity Model 720

Page 29: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxvii

CONTENTS

ftoc.indd 08/08/2015 Page xxvii

Adding Business Logic to Entities 720Plain Old CLR Objects (POCO) 720

Summary 720

CHAPTER 32: REPORTING 721

Getting Started with Reporting 721Designing Reports 723

Defi ning Data Sources 725Reporting Controls 727

Text Box 727Line/Rectangle 729Table 729Matrix 733List 734Image 735Subreport 736Chart 736Gauge 738Map 741Data Bar 741Sparkline 742Indicator 743

Expressions, Placeholders, and Aggregates 743Custom Code 747Report Layout 751Subreports 754The Report Wizard 756

Rendering Reports 757The Report Viewer Controls 757Generating the Report 758Rendering Reports to Different Formats 759

Deploying Reports 761Summary 761

PART VII: APPLICATION SERVICES 763

CHAPTER 33: WINDOWS COMMUNICATION FOUNDATION (WCF) 765

What Is WCF? 766Getting Started 766Defi ning Contracts 767

Page 30: PROFESSIONAL Visual Studio 2015€¦ · ftoc.indd 08/08/2015 Page xi CONTENTS INTRODUCTION xxxix PART I: INTEGRATED DEVELOPMENT ENVIRONMENT 1 CHAPTER 1: A QUICK TOUR 3 Getting Started

xxviii

CONTENTS

ftoc.indd 08/08/2015 Page xxviii

Creating the Service Contract 768Creating the Data Contract 770

Confi guring WCF Service Endpoints 772Hosting WCF Services 777Consuming a WCF Service 782Summary 787

CHAPTER 34: WINDOWS WORKFLOW FOUNDATION (WF) 789

What Is Windows Workfl ow Foundation? 790Why Use Windows Workfl ow? 790Workfl ow Concepts 791

Activities 791Control Flow Activities 793Expressions 793Workfl ow Run Time/Scheduler 793Bookmarks 793Persistence 794Tracking 794

Getting Started 795The Workfl ow Foundation Designer 797Creating a Workfl ow 801

Designing a Workfl ow 801Writing Code Activities 804Executing a Workfl ow 806Debugging Workfl ows 808Testing Workfl ows 809

Summary 809

CHAPTER 35: CLIENT APPLICATION SERVICES 811

Client Services 812Role Authorization 815User Authentication 817Settings 819Login Form 824Offl ine Support 827Summary 829

CHAPTER 36: SYNCHRONIZATION SERVICES 831

Occasionally Connected Applications 832Server Direct 832