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 Imag
Trang 2Professional Visual Studio® 2008
By Nick Randolph David Gardner
Trang 3Professional 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
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
Trang 4Services 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
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
Trang 5Professional Visual Studio® 2008
Trang 7Professional Visual Studio® 2008
By Nick Randolph David Gardner
Wiley Publishing, Inc.
Trang 8Professional V isual Studio® 2008
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
Trang 9About 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
Trang 10Keyvan 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
Trang 13Acknowledgments
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
Trang 14coffee 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
Trang 15Introduction xxxvii
Trang 16Other Options 39
Trang 17Summary 105
Trang 18Accessing Source Control 109
Trang 20Summary 228
Trang 21Summary 238
Summary 253
Trang 22Code Snippets Manager 260
Summary 273
Summary 288
Trang 23Summary 322
Trang 24Validation 346
Summary 363
Trang 25Summary 416
Summary 432
Trang 26Chapter 28: Cr yptography 447
Techniques 448
Trang 27Starter Kits, Community Projects, and Open-Source Applications 512
Summary 546
Trang 28Chapter 33: Office Applications 547
Summary 565
Trang 29Summary 607
Model-View-Controller 635
Summary 645
Trang 30Summary 665
Summary 676
Trang 31Summary 694
Trang 32Tracepoints 717
Trang 33Summary 775
Trang 34Chapter 48: Assembly V ersioning and Signing 795
Summary 836
The Automation Model and V isual Studio Extensibility 841
Trang 35Debugging 864 Deployment 864
Deployment 877 Summary 878
Trang 36Chapter 55: VSTS: De veloper Edition 891
Trang 37Summary 946 Index 947
Trang 39Introduction
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
Trang 40The 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
Microsoft has worked long and hard on its development tools Actually, its first software product was a
version of BASIC in 1975 Back then, programming languages were mainly interpretive languages in which
the computer would process the code to be performed line by line In the past three decades, programming
has seen many advances, one of the biggest by far being development environments aimed at helping
developers be efficient at producing applications in their chosen language and platform
In the 32 - bit computing era, Microsoft started releasing comprehensive development tools, commonly
called IDEs (short for integrated development environments), which contained not just a compiler but
also a host of other features to supplement it, including a context - sensitive editor and rudimentary
IntelliSense features that helped programmers determine what they could and couldn ’ t do in a given
situation Along with these features came intuitive visual user interface designers with drag - and - drop
functionality and associated tool windows that gave developers access to a variety of properties for the
various components on a given window or user control
Initially, these IDEs were different for each language, with Visual Basic being the most advanced in terms
of the graphical designer and ease of use, and Visual C++ having the most power and flexibility Under
the banner of Visual Studio 6, the latest versions of these languages were released in one large
development suite along with other “ Visual ” tools such as FoxPro and InterDev However, it was
obvious that each language still had a distinct environment in which to work, and as a result,
development solutions had to be in a specific language
One Comprehensive Environment
When Microsoft first released Visual Studio NET in 2002, it inherited many features and attributes of the
various, disparate development tools the company had previously offered Visual Basic 6, Visual InterDev,
Visual C++, and other tools such as FoxPro all contributed to a development effort that the Microsoft
development team mostly created on its own The team had some input from external groups, but Visual
Studio NET 2002 and NET 1.0 were primarily founded on Microsoft ’ s own principles and goals
Visual Studio NET 2003 was the next version released, and it provided mostly small enhancements and
big fixes Two years later, Visual Studio 2005 and the NET Framework 2.0 were released This was a
major new edition with new foundation framework classes that went far beyond anything Microsoft had
released previously However, the most significant part of this release was realized in the IDE where the
various components fit together in a cohesive way to provide you with an efficient tool set where
everything was easily accessible
The latest release, Visual Studio 2008 and NET Framework 3.5, builds on this strong foundation LINQ
promises to revolutionize the way you access data, and features that were previously separate
downloads, such as ASP.NET AJAX and Visual Studio Tools for Office, are now included by default