Wrox Professional Visual Studio 2008 Jul 2008 ISBN 0470229888 pdf

  

Professional

Visual Studio® 2008

  

By

Nick Randolph

David Gardner

Wiley Publishing, Inc.

  

Professional

Visual Studio® 2008

  (Continued) Introduction .................................. xxxvii

  Part I: Integrated Development Environment Chapter 1: A Quick T our ........................ 3 Chapter 2: The Solution Explorer , Toolbox, and Proper ties...... 13 Chapter 3: Options and Customizations .................. 31 Chapter 4: W orkspace Control ............ 47 Chapter 5: F ind and Replace, and Help . 63 Part II: Getting Star ted Chapter 6: Solutions, Projects, and Items ..........................

  83 Chapter 7: Source Control................. 107

  Chapter 8: F orms and Controls .......... 117 Chapter 9: Documentation Using Comments and Sandcastle ...................... 131 Chapter 10: Project and Item Templates .............. 151 Part III: Languages Chapter 11: Generics, Nullable Types, Partial Types, and Methods ................. 171

  Chapter 12: Anonymous Types, Extension Methods, and Lambda Expressions ...... 187 Chapter 13: Language-Specific Features ........................ 199 Chapter 14: The My Namespace ....... 211 Chapter 15: The Languages Ecosystem .................... 229 Part IV: Coding Chapter 16: IntelliSense and Bookmarks ............. 241 Chapter 17: Code Snippets and Refactoring ............. 255

  Chapter 18: Modeling with the Class Designer .............. 275 Chapter 19: Ser ver Explorer .............. 289 Chapter 20: Unit T esting ................... 305 Part V: Data Chapter 21: DataSets and DataBinding .................. 325 Chapter 22: V isual Database T ools .... 365 Chapter 23: Language Integrated Queries (LINQ) ............... 383 Chapter 24: LINQ to XML .................. 393 Chapter 25: LINQ to SQL and Entities ......................... 403 Chapter 26: Synchronization Services ........................ 417 Part VI: Security Chapter 27: Security in the .NET Framework ............ 435

  Chapter 28: Cr yptography ................. 447 Chapter 29: Obfuscation ................... 469

  Chapter 30: Client Application Services ........................ 481 Chapter 31: Device Security Manager ........................ 495 Part VII: Platfor ms Chapter 32: ASP.NET W eb Applications .................. 505 Chapter 33: Office Applications ......... 547 Chapter 34: Mobile Applications ....... 567 Chapter 35: WPF Applications .......... 595 Chapter 36: WCF and WF Applications .................. 609 Chapter 37: Next Generation W eb: Silverlight and ASP.NET MVC ................ 625 Part VIII: Configuration and Internationalization Chapter 38: Configuration F iles ......... 649 Chapter 39: Connection Strings ........ 667 Chapter 40: Resource F iles ............... 677 Part IX: Debugging Chapter 41: Using the Debugging Windows ....................... 697 Chapter 42: Debugging with Breakpoints ................... 711 Chapter 43: Creating Debug Proxies and Visualizers .............. 723

  Chapter 44: Debugging Web Applications .................. 735 Chapter 45: Advanced Debugging Techniques .................... 751 Part X: Build and Deplo yment Chapter 46: Upgrading with V isual Studio 2008 .................. 769 Chapter 47: Build Customization ....... 777 Chapter 48: Assembly V ersioning and Signing ................... 795

  Chapter 49: ClickOnce and MSI Deployment ................... 803 Chapter 50: Web and Mobile Application Deployment ................... 825 Part XI: Automation Chapter 51: The Automation Model ... 839 Chapter 52: Add-Ins .......................... 849 Chapter 53: Macros .......................... 867 Part XII: Visual Studio T eam System Chapter 54: VSTS: Architect Edition .......................... 881 Chapter 55: VSTS: De veloper Edition .......................... 891 Chapter 56: VSTS: T ester Edition ...... 903 Chapter 57: VSTS: Database Edition .......................... 911 Chapter 58: Team Foundation Server ........................... 923

  

Professional

Visual Studio® 2008

  

Professional

Visual Studio® 2008

  

By

Nick Randolph

David Gardner

Wiley Publishing, Inc. Professional V isual Studio® 2008

  Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana

  ISBN: 978-0-470-229880 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data is available from the publisher. 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 Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, 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 Website 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 Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites 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 (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

  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 affiliates, in the United States and other countries, and may not be used without written permission. Visual Studio is a registered trademark of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.

  Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

  About the Author s

  Nick Randolph is currently the Chief Development Officer for N Squared Solutions, having recently left his role as lead developer at Intilecta Corporation where he was integrally involved in designing and building that firm ’ s application framework. After graduating with a combined Engineering (Information Technology)/Commerce degree, Nick went on to be nominated as a Microsoft MVP in recognition of his work with the Perth .NET user group and his focus on mobile devices. He is still an active contributor in the device application development space via his blog at http://community.softteq.com/blogs/nick/ and via the Professional Visual Studio web site, http://www.professionalvisualstudio.com/ . Over the past two years, Nick has been invited to present at a variety of events including Tech Ed Australia, MEDC, and Code Camp. He has also authored articles for MSDN Magazine (ANZ edition) and a book entitled Professional Visual Studio 2005 , and has helped judge the 2004, 2005, and 2007 world finals for the Imagine Cup. David Gardner is a seasoned.NET developer and the Chief Software Architect at Intilecta Corporation. David has an ongoing passion to produce well - designed, high - quality software products that engage and delight users. For the past decade and a bit, David has worked as a solutions architect, consultant, and developer, and has provided expertise to organizations in Australia, New Zealand, and Malaysia. David is a regular speaker at the Perth .NET user group, and has presented at events including the .NET Framework Launch, TechEd Malaysia, and the Microsoft Executive Summit. He holds a Bachelor of Science (Computer Science) and is a Microsoft Certified Systems Engineer.

  David regularly blogs about Visual Studio and .NET at http://www.professionalvisualstudio .com/ , and maintains a personal web site at http://peaksite.com/ .

  Guest Author s Miguel Madero

  Miguel Madero is a Senior Developer with Readify Consulting in Australia. Miguel has architected different frameworks and solutions for disconnected mobile applications, ASP.NET, and Distributed Systems, worked with Software Factories, and trained other developers in the latest Microsoft technologies. Miguel was also the founder of DotNetLaguna, the .NET User Group in Torre ó n, Coahuila, M é xico. In his spare time Miguel enjoys being with his beautiful fianc é e, Carina, practicing rollerblading, and trying to surf at Sydney ’ s beaches. You can find Miguel ’ s blog at http://www.miguelmadero.com/ .

  Miguel wrote Chapters 54 through 58 of this book, covering Visual Studio Team Suite and Team Foundation Server.

   Keyvan Nayyeri

  Keyvan Nayyeri is a software architect and developer with a Bachelor of Science degree in Applied Mathematics. Keyvan ’ s main focus is Microsoft development and related technologies. He has published articles on many well - known .NET online communities and is an active team leader and developer for several .NET open - source projects. About the Authors

  Keyvan is the author of Professional Visual Studio Extensibility and co - authored Professional Community

  Server , also published by Wrox Press. You can find his thoughts on .NET, Community Server and Technology at . http://www.nayyeri.net/ Keyvan was a guest author on this book, writing Chapters 51 through 53 on Visual Studio Automation.

   Joel Pobar

  Joel Pobar is a habituated software tinkerer originally from sunny Brisbane, Australia. Joel was a Program Manager on the .NET Common Language Runtime team, sharing his time between late - bound dynamic CLR features (Reflection, Code Generation), compiler teams, and the Shared Source CLI program (Rotor). These days, Joel is on sabbatical, exploring the machine learning and natural language processing worlds while consulting part - time for Microsoft Consulting Services. You can find Joel ’ s recent writings at .

  http://callvirt.net/blog/ Joel lent his expertise to this book by authoring Chapter 15 on the Languages Ecosystem. Acquisitions Editor Katie Mohr Development Editor William Bridges Technical Editor s Todd Meister Keyvan Nayyeri Doug Holland Production Editor William A. Barton Copy Editor s Kim Cofer S.D. Kleinman Editorial Manager Mary Beth Wakefield

  Credits

  Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B. Wikert Project Coordinator, Cover Lynsey Osborne Proofreaders David Fine, Corina Copp, Word One Indexer Robert Swanson

  Acknowledgments

  I was expecting that writing the second edition of this book would be relatively straightforward — a little tweak here and a bit extra there — but no, the reality was that it was again one of the most time - demanding exercises I ’ ve undertaken in recent years. I must thank my partner, Cynthia, who consistently encouraged me to “ get it done, ” so that we can once again have a life.

  I would especially like to thank everyone at Wrox who has helped me re - learn the art of technical writing — in particular, Bill Bridges, whose attention to detail has resulted in consistency throughout the book despite there being five authors contributing to the process, and Katie Mohr (whose ability to get us back on track was a life - saver), who made the whole process possible.

  I have to pass on a big thank you to my co - author, David Gardner, who agreed to work with me on the second edition of this book. I doubt that I really gave an accurate representation of exactly how much work would be involved, and I really appreciated having someone of such high caliber to bounce ideas off of and share the workload. As we approached the mid - point of this book, I really appreciated a number of guest authors stepping in to help ensure we were able to meet the deadline. So a big thanks to Keyvan Nayyeri, Miguel Madero, and Joel Pobar for their respective contributions.

  Lastly, I would like to thank all of my fellow Australian MVP developers and the Microsoft staff (Dave Glover and Andrew Coates particularly), who were always able to answer any questions along the way.

   — Nick Randolph

  This book represents one of the most rewarding and challenging activities I ’ ve ever undertaken. Writing while maintaining a full - time job is certainly not for the fainthearted. However, in the process I have amassed a wealth of knowledge that I never would have found the time to learn otherwise. The process of writing a book is very different from writing code, and I am especially thankful to the team at Wrox for helping guide me to the finish line. Without Katie Mohr and Bill Bridges working as hard as they did to cajole the next chapter out of us, we never would have gotten this finished. Katie put her trust in me as a first - time author, and fully supported our decisions regarding the content and structure of the book. Bill improved the clarity and quality of my writing and corrected my repeated grammatical transgressions and Aussie colloquialisms. It was a pleasure to be in such experienced hands, and I thank them both for their patience and professionalism. A huge thank you goes to my co - author Nick Randolph, who invited me to join him in writing this book, and managed to get us organized early on when I had very little idea what I was doing. I enjoyed collaborating on such a big project and the ongoing conversations about the latest cool feature that we ’ d just discovered.

  Much appreciation and thanks go to our guest authors, Keyvan Nayyeri, Miguel Madero, and Joel Pobar, whose excellent contributions to this book have improved it significantly. Also thanks to my fellow Acknowledgments

  coffee drinkers and .NET developers, Mitch Wheat, Michael Minutillo, and Ola Karlsson, for their feedback and suggestions on how to improve various chapters. Most of all I would like to thank my beautiful and supportive wife, Julie. She certainly didn ’ t know what she was getting herself into when I agreed to write this book, but had she known I ’ ve no doubt that she would still have been just as encouraging and supportive. Julie did more than her fair share for our family when I needed to drop almost everything else, and I am truly grateful for her love and friendship. Finally, thanks to my daughters Jasmin and Emily, who gave up countless cuddles and tickles so that Daddy could find the time to write this book. I promise I ’ ll do my best to catch up on the tickles that I owe you, and pay them back with interest.

   — David Gardner

  Contents Introduction xxxvii

  25 Extending the Properties Window

  38 Tracking Changes

  37 Full-Screen Mode

  36 Visual Guides

  36 Fonts and Colors

  33 The Editor Space

  32 Docking

  32 Navigating Open Items

  31 Viewing Windows and Toolbars

  31 Window Layout

  30 Chapter 3: Options and Customizations

  27 Summary

  24 Properties

  Part I: Integrated De velopment En vironment

  23 Adding Components

  21 Arranging Components

  15 The Toolbox

  13 Common Tasks

  13 The Solution Explorer

  12 Chapter 2: The Solution Explorer , Toolbox, and Proper ties

  7 Summary

  5 Develop, Build, and Debug Your First Application

  3 The V isual Studio IDE

  3 Let’s Get Star ted

  1 Chapter 1: A Quick T our

  38 Contents Other Options

  39 Keyboard Shortcuts

  64 Quick Find and Replace Dialog Options

  58 HTML Outlining

  58 Control Outline

  59 Summary

  61 Chapter 5: F ind and Replace, and Help

  63 Introducing Find and Replace

  63 Quick Find

  66 Find in Files

  56 Code Formatting

  68 Find Dialog Options

  69 Results Window

  70 Replace in F iles

  70 Incremental Search

  71 Find Symbol

  72 Find and Replace Options

  57 Document Outline T ool Window

  56 Outlining

  39 Projects and Solutions

  47 Immediate Window

  41 Build and Run

  42 VB.NET Options

  43 Importing and Expor ting Settings

  43 Summary

  45 Chapter 4: W orkspace Control

  47 Command Window

  48 Class V iew

  55 Forward/Backward 56 Regions

  49 Object Browser

  50 Object Test Bench

  52 Invoking Static Methods

  52 Instantiating Objects

  53 Accessing Fields and Properties

  54 Invoking Instance Methods

  55 Code V iew

  73

  Contents Accessing Help

  73 Document Explorer

  74 Dynamic Help

  76 The Search Window

  76 Keeping Favorites

  78 Customizing Help

  78 Summary

  79 Part II: Getting Star ted

  81 Chapter 6: Solutions, Projects, and Items

  83 Solution Str ucture

  83 Solution File Format

  85 Solution Proper ties

  86 Common Properties

  86 Configuration Properties

  87 Project Types

  88 Project F iles Format

  90 Project Proper ties

  90 Application

  91 Compile (Visual Basic only)

  93 Build (C# only)

  95 Debug

  96 References (Visual Basic only)

  97 Resources

  98 Services

  99 Settings 100 Signing 100 My Extensions (Visual Basic only) 101 Security 102 Publish 103 Web (Web Application Projects only) 104

  Web Site Projects 104 Summary 105

Chapter 7: Source Control

  107 Selecting a Source Control Repositor y

  108 Environment Settings

  109 Plug-In Settings 109 Contents Accessing Source Control

  109 Creating the Repository

  TableLayoutPanel 128 Docking and Anchoring Controls

  IntelliSense Information 144

  Using XML Comments 143

  XML Comment Tags 133

  Adding XML Comments 132

  XML Comments 132

  

Chapter 9: Documentation Using Comments and Sandcastle 131

Inline Commenting 131

  129 Summary 130

  Panel and SplitContainer 127 FlowLayoutPanel 128

  110 Adding the Solution 111 Solution Explorer 111 Checking In and Out 112 Pending Changes 112 Merging Changes 113 History 114 Pinning 115

  Container Controls 127

  Vertically Aligning Text Controls 122 Automatic Positioning of Multiple Controls 123 Locking Control Design 124 Setting Control Properties 124 Service-Based Components 125 Smart Tag Tasks 126

  Form Design Preferences 120 Adding and Positioning Controls 121

  Appearance Properties 119 Layout Properties 119 Window Style Properties 120

  The Windows F orm 117

  Chapter 8: F orms and Controls 117

  Offline Support for Source Control 115 Summary 116

  Sandcastle Documentation Generation T ools 144

  Contents Task List Comments

  Consumption 172 Creation 173 Constraints 174

  Chapter 12: Anon ymous Types, Extension Methods, and Lambda Expressions 187

  Property Accessibility 184 Custom Events 185 Summary 186

  Operators 181 Type Conversions 182 Why Static Methods Are Bad 183

  Operator Over loading 181

  Form Designers 179 Partial Methods 180

  Nullable Types 176 Partial Types 178

  

Chapter 11: Generics, Nullable Types, Partial Types, and Methods 171

Generics 171

  147 Summary 149

  Part III: Languages 169

  Summary 167

  IWizard 161 Starter Template 164

  Template Project Setup 159

  Extending Templates 159

  Item Template 151 Project Template 155 Template Structure 156 Template Parameters 158

  

Chapter 10: Project and Item T emplates 151

Creating Templates 151

  Object and Ar ray Initialization 187 Implicit Typing 189 Anonymous Types 191 Contents Extension Methods

  193 Lambda Expressions 195 Summary 198

Chapter 13: Language-Specific F eatures 199 C#

  199 Anonymous Methods

  199 Iterators 201 Static Classes 202 Naming Conflicts 203 Pragma 206 Automatic Properties 207

VB.NET

  207 IsNot

  207 Global 208 TryCast 208 Ternary If Operator 209 Relaxed Delegates 209

  Summary 210

Chapter 14: The My Namespace

  A Namespace Over view 218

  My.Application 218 My.Computer 219 My.Forms and My.WebServices 223 My for the Web 223 My.Resources 223 Other My Classes 224

  Your Turn 224

  Methods and Properties 224 Extending the Hierarchy 225 Packaging and Deploying 226

  Summary 228

  211 Using My in Code 213

  211 What Is the My Namespace?

  Using My in C# 214 Contextual My 215 Default Instances 217

  Contents

  IntelliSense Options 247

  

Chapter 17: Code Snippets and Refactoring 255

Code Snippets Re vealed 256

  Bookmarks and the Bookmar k Window 251 Summary 253

  XML Comments 251 Adding Your Own IntelliSense 251

  Code Snippets 250

  Extended IntelliSense 250

  General Options 247 Statement Completion 249 C#-Specific Options 249

  General IntelliSense 242 Completing Words and Phrases 243 Parameter Information 246 Quick Info 247

  Chapter 15: The Languages Ecosystem 229

  

Chapter 16: IntelliSense and Bookmar ks 241

IntelliSense Explained 241

  Part IV: Coding 239

  Summary 238

  Downloading and Installing F# 233 Your First F# Program 233 Exploring F# Language Features 236

  Introducing F# 232

  Imperative 230 Declarative 230 Dynamic 230 Functional 231 What’s It All Mean? 232

  Hitting a Nail with the Right Hammer 229

  Original Code Snippets 256 “Real” Code Snippets 256 Using Snippets in Visual Basic 257 Using Snippets in C# and J# 258 Surround With Snippet 259 Contents Code Snippets Manager

  260 Creating Snippets 261 Reviewing Existing Snippets 262

  Accessing Refactoring Suppor t 264 Refactoring Actions 265

  Extract Method 265 Encapsulate Field 267 Extract Interface 268 Reorder Parameters 269 Remove Parameters 270 Rename 271 Promote Variable to Parameter 272 Generate Method Stub 272 Organize Usings 273

  Summary 273

  

Chapter 18: Modeling with the Class Designer 275

Creating a Class Diagram 275 Design Surface 276 Toolbox 277

  Entities 278 Connectors 279

  Class Details 279 Properties Window 280 Layout 281 Exporting Diagrams 281 Code Generation and Refactoring 282

  Drag-and-Drop Code Generation 282 IntelliSense Code Generation 284 Refactoring with the Class Designer 284

  PowerToys for the Class Designer 285

  Visualization Enhancements 285 Functionality Enhancements 287

  Summary 288

  Chapter 19: Ser ver Explorer 289

  The Ser vers Node 290

  Event Logs 290 Management Classes 293 Management Events 295

  Contents Message Queues

  Data 316 Writing Test Output 317

  BindingSource 332 BindingNavigator 334

  Binding 331

  Adding a Data Source 326 DataSet Designer 328

  DataSet Over view 325

  Chapter 21: DataSets and DataBinding 325

  Part V: Data 323

  Managing Large Numbers of Tests 321 Summary 322

  319 Testing Private Members 320

  Advanced 318 Custom Properties

  Testing Context 316

  297 Performance Counters 299 Services 303

  TestInitialize and TestCleanup 315 ClassInitialize and ClassCleanup 315 AssemblyInitialize and AssemblyCleanup 315

  Initializing and Cleaning Up 315

  ExpectedException Attribute 314

  Assert 312 StringAssert 313 CollectionAssert 313

  Asser ting the Facts 312

  Test Attributes 310 Test Attributes 311

  Your First Test Case 305

  Chapter 20: Unit T esting 305

  Summary 304

  Data Source Selections 336 BindingSource Chains 338 Saving Changes 343 Inserting New Items 345 Contents Validation

  346 DataGridView 353

  Object Data Source 355

  IDataErrorInfo 359

  Working with Data Sources 359

  Web Service Data Source 360 Browsing Data 361

  Summary 363

  Chapter 22: V isual Database T ools 365

  Database Windows in V isual Studio 2008 365 Server Explorer

  366 Table Editing 368 Relationship Editing 369 Views 370 Stored Procedures and Functions 371 Database Diagrams 373 Data Sources Window 374

  Managing Test Data 379 Previewing Data 380 Summary 381

  

Chapter 23: Language Integrated Queries (LINQ) 383

LINQ Providers 383 Old-School Queries 384 Query Pieces 386

  From 386 Select 387 Where 388 Group By 389 Custom Projections 389 Order By 390

  Debugging and Execution 390 Summary 391

  Chapter 24: LINQ to XML 393

  XML Object Model 393

  VB.NET XML Literals 394 Paste XML as XElement 395

  Contents Creating XML with LINQ

  Server Direct 418 Getting Started with Synchronization Services 420

  User Identities 443 Walkthrough of Role-Based Security 444

  Role-Based Security 442

  Permission Sets 438 Evidence and Code Groups 438 Security Policy 439 Walkthrough of Code Access Security 440

  

Chapter 27: Security in the .NET F ramework 435

Key Security Concepts 435 Code Access Security 437

  Part VI: Security 433

  Summary 432

  Synchronization Services over N-Tiers 425 Background Synchronization 429 Client Changes 431

  Occasionally Connected Applications 417

  397 Expression Holes

  Chapter 26: Synchronization Ser vices 417

  LINQ to Entities 414 Summary 416

  Creating the Object Model 404 Querying with LINQ to SQL 407 Binding LINQ to SQL Objects 411

  LINQ to SQL 403

  Chapter 25: LINQ to SQL and Entities 403

  398 Schema Suppor t 400 Summary 402

  397 Querying XML

  Summary 445 Contents

  Chapter 28: Cr yptography 447

  General Principles 447 Techniques 448

  Hashing 448 Symmetric (Secret) Keys 449 Asymmetric (Public/Private) Keys 450 Signing 450 Summary of Goals 451

  Applying Cr yptography 451

  Creating Asymmetric Key Pairs 451 Creating a Symmetric Key 453 Encrypting and Signing the Key 454 Verifying Key and Signature 457 Decrypting the Symmetric Key 458 Sending a Message 460 Receiving a Message 462

  Miscellaneous 464 SecureString

  464 Key Containers 467

  Summary 468

  Chapter 29: Obfuscation 469

  MSIL Disassembler 469 Decompilers 471

  Obfuscating Your Code 472

  Dotfuscator 472 Words of Caution 475

  Attributes 477 ObfuscationAssemblyAttribute 477 ObfuscationAttribute 478

  Summary 479

  

Chapter 30: Client Application Ser vices 481

Client Ser vices 481 Role Authorization 484 User Authentication 485 Settings 487 Login Form 491 Offline Support 492 Summary 494

  Contents

  The HTML Designer 513 Positioning Controls and HTML Elements 515 Formatting Controls and HTML Elements 518 CSS Tools 519 Validation Tools 524

  Security 543 Application Settings 545 ASP.NET Configuration in IIS 545

  ASP.NET W eb Site Administration 542

  Developing with JavaScript 536 Working with ASP.NET AJAX 537 Using AJAX Control Extenders 540

  Master Pages 534 Rich Client-Side De velopment 535

  Navigation Components 527 User Authentication 528 Data Components 530 Web Parts 533

  Web Controls 526

  Designing Web Forms 513

  Chapter 31: De vice Security Manager 495

  Creating a Web Site Project 507 Creating a Web Application Project 510 Other Web Projects 511 Starter Kits, Community Projects, and Open-Source Applications 512

  

Chapter 32: ASP.NET W eb Applications 505

Web Application vs. W eb Site Projects 505 Creating Web Projects 506

  Part VII: Platfor ms 503

  Summary 502

  Device Emulator Manager 501 Connecting 501 Cradling 501

  Security Configurations 495 Device Emulation 500

  Summary 546 Contents

  Chapter 33: Office Applications 547

  Getting Star ted 567 The Design Skin 569

  Configuration 590 Forms 591 PocketOutlook 592 Status 592 Telephony 592 The Notification Broker 593

  Windows Mobile APIs 590

  The DataSet 582 The ResultSet 590

  Debugging 579 Project Settings 580 The Data Source 580

  Common Controls 571 Mobile Controls 572

  The Toolbox 571

  Orientation 570 Buttons 570

  Chapter 34: Mobile Applications 567

  Choosing an Office Project T ype 548

  Deploying Office Applications 564 Summary 565

  Unregistering an Add-In 562 Disabled Add-Ins 563

  Debugging Office Applications 561

  Some Outlook Concepts 557 Creating an Outlook Form Region 558

  Creating an Application Add-In 557

  552 Protecting the Document Design 555 Adding an Actions Pane 555

  Creating a Document-Le vel Customization 551 Your First VSTO Project

  Document-Level Customizations 549 Application-Level Add-In 549 SharePoint Workflow 550 InfoPath Form Template 551

  Summary 594

  Contents

  634 Model-View-Controller 635 Getting Started with ASP.NET MVC

  Section: configurationSections 651 Section: startup 652

  Configuration Schema 651

  Machine.Config 649 Web.Config 649 App.Config 650 Security.Config 650

  Config Files 649

  

Part VIII: Configuration and Inter nationalization 647

Chapter 38: Configuration F iles 649

  Summary 645

  636 Controllers and Action Methods 638 Rendering a UI with Views 641 Custom URL Routing 644

  

Chapter 37: Next Generation W eb: Silver light and ASP.NET MVC 625

Silverlight 626 Getting Started with Silverlight 2 627 Interacting with Your Web Page 631 Hosting Silverlight Applications 633

  Chapter 35: WPF Applications 595

  Windows Workflow Foundation 617 Summary 623

  Consuming a WCF Service 615

  Windows Communication F oundation 609

  Chapter 36: WCF and WF Applications 609

  Styling Your Application 601 Windows Forms Interoperability 605 Summary 607

  Manipulating Controls 598 Properties and Events 600

  Getting Star ted 595 WPF Designer 597

ASP.NET MVC

  Contents Section: runtime

  652 Section: system.runtime.remoting 653 Section: system.net 653 Section: cryptographySettings 654 Section: system.diagnostics 654 Section: system.web 655 Section: webserver 655 Section: compiler 656 Configuration Attributes 656

  Application Settings 657

  Using appSettings 657 Project Settings 658 Dynamic Properties 659 Custom Configuration Sections 660

  Referenced Projects with Settings 664 Summary 665

  Chapter 39: Connection Strings 667

  Connection String Wizard 667 SQL Ser ver Format 672 In-Code Constr uction 673 Encrypting Connection Strings 674 Summary 676

  Chapter 40: Resource F iles 677

  What Are Resources? 677

  Text File Resources 677 Resx Resource Files 679 Binary Resources 680 Adding Resources 680 Embedding Files as Resources 681 Naming Resources 681 Accessing Resources 682 Designer Files 682

  Resourcing Your Application 683

  Control Images 685

  Satellite Resources 686

  Cultures 686 Creating Culture Resources 686 Loading Culture Resource Files 687 Satellite Culture Resources 688

  Contents Accessing Specifics

  QuickWatch 701 Watch Windows 1–4 702 Autos and Locals 703

  Summary 710

  708 Unwinding an Exception 709

  Exceptions 707 Customizing the Exception Assistant

  Memory Windows 1–4 705 Disassembly 706 Registers 706

  Memory Windows 705

  Call Stack 703 Threads 704 Modules 704 Processes 705

  Breakpoint Window 698 Output Window 699 Immediate Window 700 Watch Windows 701

  688 Bitmap and Icon Loading

  Breakpoints 698 Datatips 698

  

Chapter 41: Using the Debugging Windows 697

Code Window 697

  Part IX: Debugging 695

  Custom Resources 692 Summary 694

  ResourceReader and ResourceWriter 691 ResxResourceReader and ResxResourceWriter 691

  Coding Resource F iles 690

  688 Cross-Assembly Referencing 689 ComponentResourceManager 689

  

Chapter 42: Debugging with Breakpoints 711 Breakpoints 711 Setting a Breakpoint 712 Adding Break Conditions 714 Working with Breakpoints 717 Contents Tracepoints 717

  Creating a Tracepoint 718 Tracepoint Actions 718

  Execution P oint 719

  Stepping Through Code 719 Moving the Execution Point 720

  Edit and Continue 720

  Rude Edits 721 Stop Applying Changes 721

  Summary 721

  

Chapter 43: Creating Debug Proxies and V isualizers 723

Attributes 723 DebuggerBrowsable 724 DebuggerDisplay 724 DebuggerHidden 725 DebuggerStepThrough 726 DebuggerNonUserCode 726 DebuggerStepperBoundary 727 Type Proxies 727

  Raw View 729

  Visualizers 729 Advanced Techniques 732

  Saving Changes to Your Object 732

  Summary 733

  

Chapter 44: Debugging W eb Applications 735

Debugging Ser ver-Side ASP.NET Code 735

  Web-Application Exceptions 737 Edit and Continue 740 Error Handling 740

  Debugging Client-Side Ja vaScript 741

  Setting Breakpoints in JavaScript Code 741 Debugging Dynamically Generated JavaScript 742

  Debugging ASP.NET AJAX JavaScript 743

  Debugging Silverlight 743 Tracing 744

  Page-Level Tracing 744 Application-Level Tracing 746 Trace Output 746

  Contents Trace Viewer

  747 Custom Trace Output 747

  Health Monitoring 748 Summary 750

  

Chapter 45: Advanced Debugging T echniques 751

Start Actions 751 Debugging with Code 753

  The Debugger Class 754 The Debug and Trace Classes 754

  Debugging Running Applications 756

  Attaching to a Windows Process 757 Attaching to a Web Application 757 Remote Debugging 759

  .NET Framework Reference Source 760 Multi-Threaded Debugging 763 Debugging SQL Ser ver Stored Procedures 764

  Mixed-Mode Debugging 765 Summary 766

  Part X: Build and Deplo yment 767

  

Chapter 46: Upgrading with V isual Studio 2008 769

Upgrading from V isual Studio 2005 769 Upgrading to .NET F ramework v3.5 773 Upgrading from V isual Basic 6 774 Summary 775

  Chapter 47: Build Customization 777

  General Build Options 777 Manual Dependencies 780 Visual Basic Compile P age 781

  Advanced Compiler Settings 782 Build Events 783

  C# Build P ages 785 MSBuild 787

  How Visual Studio Uses MSBuild 787 MSBuild Schema 791

  Summary 793 Contents

  

Chapter 48: Assembly V ersioning and Signing 795

Assembly Naming 795

  Mobile Application Deplo yment 831

  Development Tools Extensibility (DTE) 842 A Quick Over view of DTE 844

  Introduction to the Automation Model 840 The Automation Model and V isual Studio Extensibility 841

  Chapter 51: The Automation Model 839

  Part XI: Automation 837

  Summary 836

  CAB Files 831 MSI Installer 833

  Publish Web Site 825 Copy Web Project 827 Web Deployment Projects 827 Web Project Installers 830

  Version Consistency 797 Strong-Named Assemblies 798 The Global Assembly Cache 799 Signing an Assembly 799

  

Chapter 50: W eb and Mobile Application Deplo yment 825

Web Application Deplo yment 825

  Summary 824

  817 Click to Update 822

  ClickOnce 817 Click to Deploy

  

Chapter 49: ClickOnce and MSI Deplo yment 803

Installers 803 Building an Installer 803 Customizing the Installer 809 Adding Custom Actions 812 Service Installer 814

  Summary 801

  Solutions and Projects 844 Documents and Windows 845

  Contents Commands

  846 Debugger 847

  Limitations of the Automation Model 847 Summary 848

  Chapter 52: Add-Ins 849

  Introduction 850 Add-In Wizard 851 The Anatom y of an Add-In 855 The Str ucture of .AddIn F iles 860 Develop an Add-In 861 Debugging 864

  Deployment 864 Shared Add-Ins 865 Summary 866

  Chapter 53: Macros 867

  The Anatom y of a Macro 868 Macro Explorer 869 Macros IDE 869 How to Record a Macro 871 How to De velop a Macro 872 Running a Macro 876 Deployment 877

  Summary 878

  

Part XII: V isual Studio T eam System 879

Chapter 54: VSTS: Architect Edition 881

  Case Study 881 Application Designer 882 Logical Datacenter Designer 884 Deployment Designer 885 Settings and Constraints Editor 886 System Designer 887 Summary 889 Contents

  Chapter 55: VSTS: De veloper Edition 891

  Code Metrics 891

  Lines of Code 892 Depth of Inheritance 893 Class Coupling 893 Cyclomatic Complexity 893 Maintainability Index 893 Excluded Code 893

  Managed Code Analysis T ool 893 C/C++ Code Analysis T ool 895 Profiling Tools 895

  Configuring Profiler Sessions 896 Reports 897

  Stand-Alone Profiler 898 Application Verifier 898 Code Coverage 899 Summary 901

  Chapter 56: VSTS: T ester Edition 903

  Web Tests 903 Load Tests 906

  Test Load Agent 908

  Manual Tests 908 Generic Tests 908 Ordered Tests 908 Test Management 909 Summary 909

  Chapter 57: VSTS: Database Edition 911

  SQL-CLR Database Project 911 Offline Database Schema 912 Data Generation 914 Database Unit T esting 916 Database Refactoring 917 Schema Compare 918 Data Compare 919 T-SQL Editor 920 Power Tools 920 Best Practices 921 Summary 921

  Contents

Chapter 58: T eam Foundation Ser ver

  923 Process T emplates

  923 Work Item T racking 925

  Initial Work Items 926 Work Item Queries 926 Work Item Types 928 Adding Work Items 929

  Excel and Project Integration 929

  Excel 929 Project 930

  Version Control 932

  Working from Solution Explorer 932 Check Out 933 Check In 934 History 935 Annotate 935 Resolve Conflicts 936 Working Offline 937 Label 937 Shelve 939 Branch 939

  Team Foundation Build 939 Reporting and Business Intelligence 941 Team Portal 942

  Documents 943 Process Guidance 943 SharePoint Lists 943

  Team System W eb Access 943 TFS Automation and Process Customization 944

  Work Item Types 944 Customizing the Process Template 945

  Summary 946 Index 947

  Introduction

  Visual Studio 2008 is an enormous product no matter which way you look at it. Incorporating the latest advances in Microsoft ’ s premier programming languages, Visual Basic and C#, along with a host of improvements and new features in the user interface, it can be intimidating to both newcomers and experienced .NET developers.

  Professional Visual Studio 2008 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 2008, 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 it works both in isolation and in conjunction with other parts of Visual Studio to make your development efforts even more efficient.

  Who This Book Is F or

  Professional Visual Studio 2008 is for all developers new to Visual Studio as well as those programmers who have some experience but want to learn about features they may have previously overlooked. If you are familiar with the way previous versions of Visual Studio worked, you may want to skip Part I, which deals with the basic constructs that make up the user interface, and move on to the remainder of the book where the new features found in Visual Studio 2008 are discussed in detail. If you ’ re just starting out, you ’ ll greatly benefit from the first part, where basic concepts are explained and you ’ re introduced to the user interface and how to customize it to suit your own style. This book does assume that you are familiar with the traditional programming model, and it uses both the C# and Visual Basic languages to illustrate features within Visual Studio 2008. 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 2008 by Thearon Willis and Bryan Newsome. Similarly, if you are after a great book on C#, track down Beginning Visual C# 2008, written collaboratively by a host of authors.

  What This Book Co vers

  Microsoft Visual Studio 2008 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 iterations of the theme of development environments. Introduction

  The next few pages introduce you to Microsoft Visual Studio 2008, how it came about, and what it can do for you as a developer. If you ’ re already familiar with what Visual Studio is and how it came to be, you may want to skip ahead to the next chapter and dive into the various aspects of the integrated development environment itself.

   A Brief History of Visual Studio