ProfessionalVisual Studio® 2008
By Nick Randolph David Gardner
Wiley Publishing, Inc.
ffirs.indd vffirs.indd v 6/23/08 9:30:23 AM6/23/08 9:30:23 AM
ffirs.indd ivffirs.indd iv 6/23/08 9:30:22 AM6/23/08 9:30:22 AM
ProfessionalVisual Studio® 2008
(Continued)
Introduction .................................. xxxvii
Part I: Integrated Development Environment
Chapter 1: A Quick Tour ........................ 3
Chapter 2: The Solution Explorer, Toolbox, and Properties...... 13
Chapter 3: Options and Customizations .................. 31
Chapter 4: Workspace Control ............ 47
Chapter 5: Find and Replace, and Help . 63
Part II: Getting StartedChapter 6: Solutions, Projects,
and Items .......................... 83
Chapter 7: Source Control................. 107
Chapter 8: Forms and Controls .......... 117
Chapter 9: Documentation Using Comments and Sandcastle ...................... 131
Chapter 10: Project and Item Templates .............. 151
Part III: LanguagesChapter 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: CodingChapter 16: IntelliSense
and Bookmarks ............. 241
Chapter 17: Code Snippets and Refactoring ............. 255
Chapter 18: Modeling with the Class Designer .............. 275
Chapter 19: Server Explorer .............. 289
Chapter 20: Unit Testing ................... 305
Part V: DataChapter 21: DataSets and
DataBinding .................. 325
Chapter 22: Visual Database Tools .... 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: SecurityChapter 27: Security in the
.NET Framework ............ 435
Chapter 28: Cryptography ................. 447
Chapter 29: Obfuscation ................... 469
ffirs.indd iffirs.indd i 6/23/08 9:30:20 AM6/23/08 9:30:20 AM
Chapter 30: Client Application Services ........................ 481
Chapter 31: Device Security Manager ........................ 495
Part VII: PlatformsChapter 32: ASP.NET Web
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 Web: Silverlight and ASP.NET MVC ................ 625
Part VIII: Configuration and Internationalization
Chapter 38: Configuration Files ......... 649
Chapter 39: Connection Strings ........ 667
Chapter 40: Resource Files ............... 677
Part IX: DebuggingChapter 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 DeploymentChapter 46: Upgrading with Visual
Studio 2008 .................. 769
Chapter 47: Build Customization ....... 777
Chapter 48: Assembly Versioning and Signing ................... 795
Chapter 49: ClickOnce and MSI Deployment ................... 803
Chapter 50: Web and Mobile Application Deployment ................... 825
Part XI: AutomationChapter 51: The Automation Model ... 839
Chapter 52: Add-Ins .......................... 849
Chapter 53: Macros .......................... 867
Part XII: Visual Studio Team System
Chapter 54: VSTS: Architect Edition .......................... 881
Chapter 55: VSTS: Developer Edition .......................... 891
Chapter 56: VSTS: Tester Edition ...... 903
Chapter 57: VSTS: Database Edition .......................... 911
Chapter 58: Team Foundation Server ........................... 923
ffirs.indd iiffirs.indd ii 6/23/08 9:30:22 AM6/23/08 9:30:22 AM
ProfessionalVisual Studio® 2008
ffirs.indd iiiffirs.indd iii 6/23/08 9:30:22 AM6/23/08 9:30:22 AM
ffirs.indd ivffirs.indd iv 6/23/08 9:30:22 AM6/23/08 9:30:22 AM
ProfessionalVisual Studio® 2008
By Nick Randolph David Gardner
Wiley Publishing, Inc.
ffirs.indd vffirs.indd v 6/23/08 9:30:23 AM6/23/08 9:30:23 AM
Professional Visual Studio® 2008Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
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.
ffirs.indd viffirs.indd vi 6/23/08 9:30:23 AM6/23/08 9:30:23 AM
About the Authors 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 Authors 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.
ffirs.indd viiffirs.indd vii 6/23/08 9:30:24 AM6/23/08 9:30:24 AM
viii
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.
About the Authors
ffirs.indd viiiffirs.indd viii 6/23/08 9:30:24 AM6/23/08 9:30:24 AM
Acquisitions EditorKatie Mohr
Development EditorWilliam Bridges
Technical EditorsTodd Meister Keyvan Nayyeri Doug Holland
Production EditorWilliam A. Barton
Copy EditorsKim Cofer S.D. Kleinman
Editorial ManagerMary Beth Wakefield
CreditsProduction ManagerTim Tate
Vice President and Executive Group PublisherRichard Swadley
Vice President and Executive PublisherJoseph B. Wikert
Project Coordinator, CoverLynsey Osborne
ProofreadersDavid Fine, Corina Copp,Word One
IndexerRobert Swanson
ffirs.indd ixffirs.indd ix 6/23/08 9:30:25 AM6/23/08 9:30:25 AM
ffirs.indd xffirs.indd x 6/23/08 9:30:25 AM6/23/08 9:30:25 AM
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
ffirs.indd xiffirs.indd xi 6/23/08 9:30:25 AM6/23/08 9:30:25 AM
xii
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
Acknowledgments
ffirs.indd xiiffirs.indd xii 6/23/08 9:30:25 AM6/23/08 9:30:25 AM
Contents
Introduction xxxvii
Part I: Integrated Development Environment 1
Chapter 1: A Quick Tour 3
Let’s Get Started 3The Visual Studio IDE 5
Develop, Build, and Debug Your First Application 7Summary 12
Chapter 2: The Solution Explorer, Toolbox, and Properties 13
The Solution Explorer 13Common Tasks 15
The Toolbox 21Arranging Components 23Adding Components 24
Properties 25Extending the Properties Window 27
Summary 30
Chapter 3: Options and Customizations 31
Window Layout 31Viewing Windows and Toolbars 32Navigating Open Items 32Docking 33
The Editor Space 36Fonts and Colors 36Visual Guides 37Full-Screen Mode 38Tracking Changes 38
ftoc.indd xiiiftoc.indd xiii 6/24/08 12:21:41 AM6/24/08 12:21:41 AM
Contents
xiv
Other Options 39Keyboard Shortcuts 39Projects and Solutions 41Build and Run 42VB.NET Options 43
Importing and Exporting Settings 43Summary 45
Chapter 4: Workspace Control 47
Command Window 47Immediate Window 48Class View 49Object Browser 50Object Test Bench 52
Invoking Static Methods 52Instantiating Objects 53Accessing Fields and Properties 54Invoking Instance Methods 55
Code View 55Forward/Backward 56Regions 56Outlining 56Code Formatting 57
Document Outline Tool Window 58HTML Outlining 58
Control Outline 59Summary 61
Chapter 5: Find and Replace, and Help 63
Introducing Find and Replace 63Quick Find 64Quick Find and Replace Dialog Options 66
Find in Files 68Find Dialog Options 69Results Window 70
Replace in Files 70Incremental Search 71Find Symbol 72Find and Replace Options 73
ftoc.indd xivftoc.indd xiv 6/24/08 12:21:41 AM6/24/08 12:21:41 AM
Contents
xv
Accessing Help 73Document Explorer 74Dynamic Help 76
The Search Window 76Keeping Favorites 78Customizing Help 78Summary 79
Part II: Getting Started 81
Chapter 6: Solutions, Projects, and Items 83
Solution Structure 83Solution File Format 85Solution Properties 86
Common Properties 86Configuration Properties 87
Project Types 88Project Files Format 90Project Properties 90
Application 91Compile (Visual Basic only) 93Build (C# only) 95Debug 96References (Visual Basic only) 97Resources 98Services 99Settings 100Signing 100My Extensions (Visual Basic only) 101Security 102Publish 103Web (Web Application Projects only) 104
Web Site Projects 104Summary 105
Chapter 7: Source Control 107
Selecting a Source Control Repository 108Environment Settings 109Plug-In Settings 109
ftoc.indd xvftoc.indd xv 6/24/08 12:21:42 AM6/24/08 12:21:42 AM
Contents
xvi
Accessing Source Control 109Creating the Repository 110Adding the Solution 111Solution Explorer 111Checking In and Out 112Pending Changes 112Merging Changes 113History 114Pinning 115
Offline Support for Source Control 115Summary 116
Chapter 8: Forms and Controls 117
The Windows Form 117Appearance Properties 119Layout Properties 119Window Style Properties 120
Form Design Preferences 120Adding and Positioning Controls 121
Vertically Aligning Text Controls 122Automatic Positioning of Multiple Controls 123Locking Control Design 124Setting Control Properties 124Service-Based Components 125Smart Tag Tasks 126
Container Controls 127Panel and SplitContainer 127FlowLayoutPanel 128TableLayoutPanel 128
Docking and Anchoring Controls 129Summary 130
Chapter 9: Documentation Using Comments and Sandcastle 131
Inline Commenting 131XML Comments 132
Adding XML Comments 132XML Comment Tags 133
Using XML Comments 143IntelliSense Information 144
Sandcastle Documentation Generation Tools 144
ftoc.indd xviftoc.indd xvi 6/24/08 12:21:42 AM6/24/08 12:21:42 AM
Contents
xvii
Task List Comments 147Summary 149
Chapter 10: Project and Item Templates 151
Creating Templates 151Item Template 151Project Template 155Template Structure 156Template Parameters 158
Extending Templates 159Template Project Setup 159IWizard 161Starter Template 164
Summary 167
Part III: Languages 169
Chapter 11: Generics, Nullable Types, Partial Types, and Methods 171
Generics 171Consumption 172Creation 173Constraints 174
Nullable Types 176Partial Types 178
Form Designers 179Partial Methods 180
Operator Overloading 181Operators 181Type Conversions 182Why Static Methods Are Bad 183
Property Accessibility 184Custom Events 185Summary 186
Chapter 12: Anonymous Types, Extension Methods, and Lambda Expressions 187
Object and Array Initialization 187Implicit Typing 189Anonymous Types 191
ftoc.indd xviiftoc.indd xvii 6/24/08 12:21:42 AM6/24/08 12:21:42 AM
Contents
xviii
Extension Methods 193Lambda Expressions 195Summary 198
Chapter 13: Language-Specific Features 199
C# 199Anonymous Methods 199Iterators 201Static Classes 202Naming Conflicts 203Pragma 206Automatic Properties 207
VB.NET 207IsNot 207Global 208TryCast 208Ternary If Operator 209Relaxed Delegates 209
Summary 210
Chapter 14: The My Namespace 211
What Is the My Namespace? 211Using My in Code 213
Using My in C# 214Contextual My 215Default Instances 217
A Namespace Overview 218My.Application 218My.Computer 219My.Forms and My.WebServices 223My for the Web 223My.Resources 223Other My Classes 224
Your Turn 224Methods and Properties 224Extending the Hierarchy 225Packaging and Deploying 226
Summary 228
ftoc.indd xviiiftoc.indd xviii 6/24/08 12:21:43 AM6/24/08 12:21:43 AM
Contents
xix
Chapter 15: The Languages Ecosystem 229
Hitting a Nail with the Right Hammer 229Imperative 230Declarative 230Dynamic 230Functional 231What’s It All Mean? 232
Introducing F# 232Downloading and Installing F# 233Your First F# Program 233Exploring F# Language Features 236
Summary 238
Part IV: Coding 239
Chapter 16: IntelliSense and Bookmarks 241
IntelliSense Explained 241General IntelliSense 242Completing Words and Phrases 243Parameter Information 246Quick Info 247
IntelliSense Options 247General Options 247Statement Completion 249C#-Specific Options 249
Extended IntelliSense 250Code Snippets 250XML Comments 251Adding Your Own IntelliSense 251
Bookmarks and the Bookmark Window 251Summary 253
Chapter 17: Code Snippets and Refactoring 255
Code Snippets Revealed 256Original Code Snippets 256“Real” Code Snippets 256Using Snippets in Visual Basic 257Using Snippets in C# and J# 258Surround With Snippet 259
ftoc.indd xixftoc.indd xix 6/24/08 12:21:43 AM6/24/08 12:21:43 AM
Contents
xx
Code Snippets Manager 260Creating Snippets 261Reviewing Existing Snippets 262
Accessing Refactoring Support 264Refactoring Actions 265
Extract Method 265Encapsulate Field 267Extract Interface 268Reorder Parameters 269Remove Parameters 270Rename 271Promote Variable to Parameter 272Generate Method Stub 272Organize Usings 273
Summary 273
Chapter 18: Modeling with the Class Designer 275
Creating a Class Diagram 275Design Surface 276Toolbox 277
Entities 278Connectors 279
Class Details 279Properties Window 280Layout 281Exporting Diagrams 281Code Generation and Refactoring 282
Drag-and-Drop Code Generation 282IntelliSense Code Generation 284Refactoring with the Class Designer 284
PowerToys for the Class Designer 285Visualization Enhancements 285Functionality Enhancements 287
Summary 288
Chapter 19: Server Explorer 289
The Servers Node 290Event Logs 290Management Classes 293Management Events 295
ftoc.indd xxftoc.indd xx 6/24/08 12:21:43 AM6/24/08 12:21:43 AM
Contents
xxi
Message Queues 297Performance Counters 299Services 303
Summary 304
Chapter 20: Unit Testing 305
Your First Test Case 305Test Attributes 310Test Attributes 311
Asserting the Facts 312Assert 312StringAssert 313CollectionAssert 313ExpectedException Attribute 314
Initializing and Cleaning Up 315TestInitialize and TestCleanup 315ClassInitialize and ClassCleanup 315AssemblyInitialize and AssemblyCleanup 315
Testing Context 316Data 316Writing Test Output 317
Advanced 318Custom Properties 319Testing Private Members 320
Managing Large Numbers of Tests 321Summary 322
Part V: Data 323
Chapter 21: DataSets and DataBinding 325
DataSet Overview 325Adding a Data Source 326DataSet Designer 328
Binding 331BindingSource 332BindingNavigator 334Data Source Selections 336BindingSource Chains 338Saving Changes 343Inserting New Items 345
ftoc.indd xxiftoc.indd xxi 6/24/08 12:21:44 AM6/24/08 12:21:44 AM
Contents
xxii
Validation 346DataGridView 353
Object Data Source 355IDataErrorInfo 359
Working with Data Sources 359Web Service Data Source 360Browsing Data 361
Summary 363
Chapter 22: Visual Database Tools 365
Database Windows in Visual Studio 2008 365Server Explorer 366Table Editing 368Relationship Editing 369Views 370Stored Procedures and Functions 371Database Diagrams 373Data Sources Window 374
Managing Test Data 379Previewing Data 380Summary 381
Chapter 23: Language Integrated Queries (LINQ) 383
LINQ Providers 383Old-School Queries 384Query Pieces 386
From 386Select 387Where 388Group By 389Custom Projections 389Order By 390
Debugging and Execution 390Summary 391
Chapter 24: LINQ to XML 393
XML Object Model 393VB.NET XML Literals 394Paste XML as XElement 395
ftoc.indd xxiiftoc.indd xxii 6/24/08 12:21:44 AM6/24/08 12:21:44 AM
Contents
xxiii
Creating XML with LINQ 397Expression Holes 397
Querying XML 398Schema Support 400Summary 402
Chapter 25: LINQ to SQL and Entities 403
LINQ to SQL 403Creating the Object Model 404Querying with LINQ to SQL 407Binding LINQ to SQL Objects 411
LINQ to Entities 414Summary 416
Chapter 26: Synchronization Services 417
Occasionally Connected Applications 417Server Direct 418Getting Started with Synchronization Services 420Synchronization Services over N-Tiers 425Background Synchronization 429Client Changes 431
Summary 432
Part VI: Security 433
Chapter 27: Security in the .NET Framework 435
Key Security Concepts 435Code Access Security 437
Permission Sets 438Evidence and Code Groups 438Security Policy 439Walkthrough of Code Access Security 440
Role-Based Security 442User Identities 443Walkthrough of Role-Based Security 444
Summary 445
ftoc.indd xxiiiftoc.indd xxiii 6/24/08 12:21:44 AM6/24/08 12:21:44 AM
Contents
xxiv
Chapter 28: Cryptography 447
General Principles 447Techniques 448
Hashing 448Symmetric (Secret) Keys 449Asymmetric (Public/Private) Keys 450Signing 450Summary of Goals 451
Applying Cryptography 451Creating Asymmetric Key Pairs 451Creating a Symmetric Key 453Encrypting and Signing the Key 454Verifying Key and Signature 457Decrypting the Symmetric Key 458Sending a Message 460Receiving a Message 462
Miscellaneous 464SecureString 464Key Containers 467
Summary 468
Chapter 29: Obfuscation 469
MSIL Disassembler 469Decompilers 471Obfuscating Your Code 472
Dotfuscator 472Words of Caution 475
Attributes 477ObfuscationAssemblyAttribute 477ObfuscationAttribute 478
Summary 479
Chapter 30: Client Application Services 481
Client Services 481Role Authorization 484User Authentication 485Settings 487Login Form 491Offline Support 492Summary 494
ftoc.indd xxivftoc.indd xxiv 6/24/08 12:21:44 AM6/24/08 12:21:44 AM
Contents
xxv
Chapter 31: Device Security Manager 495
Security Configurations 495Device Emulation 500
Device Emulator Manager 501Connecting 501Cradling 501
Summary 502
Part VII: Platforms 503
Chapter 32: ASP.NET Web Applications 505
Web Application vs. Web Site Projects 505Creating Web Projects 506
Creating a Web Site Project 507Creating a Web Application Project 510Other Web Projects 511Starter Kits, Community Projects, and Open-Source Applications 512
Designing Web Forms 513The HTML Designer 513Positioning Controls and HTML Elements 515Formatting Controls and HTML Elements 518CSS Tools 519Validation Tools 524
Web Controls 526Navigation Components 527User Authentication 528Data Components 530Web Parts 533
Master Pages 534Rich Client-Side Development 535
Developing with JavaScript 536Working with ASP.NET AJAX 537Using AJAX Control Extenders 540
ASP.NET Web Site Administration 542Security 543Application Settings 545ASP.NET Configuration in IIS 545
Summary 546
ftoc.indd xxvftoc.indd xxv 6/24/08 12:21:44 AM6/24/08 12:21:44 AM
Contents
xxvi
Chapter 33: Office Applications 547
Choosing an Office Project Type 548Document-Level Customizations 549Application-Level Add-In 549SharePoint Workflow 550InfoPath Form Template 551
Creating a Document-Level Customization 551Your First VSTO Project 552Protecting the Document Design 555Adding an Actions Pane 555
Creating an Application Add-In 557Some Outlook Concepts 557Creating an Outlook Form Region 558
Debugging Office Applications 561Unregistering an Add-In 562Disabled Add-Ins 563
Deploying Office Applications 564Summary 565
Chapter 34: Mobile Applications 567
Getting Started 567The Design Skin 569
Orientation 570Buttons 570
The Toolbox 571Common Controls 571Mobile Controls 572
Debugging 579Project Settings 580The Data Source 580
The DataSet 582The ResultSet 590
Windows Mobile APIs 590Configuration 590Forms 591PocketOutlook 592Status 592Telephony 592The Notification Broker 593
Summary 594
ftoc.indd xxviftoc.indd xxvi 6/24/08 12:21:45 AM6/24/08 12:21:45 AM
Contents
xxvii
Chapter 35: WPF Applications 595
Getting Started 595WPF Designer 597
Manipulating Controls 598Properties and Events 600
Styling Your Application 601Windows Forms Interoperability 605Summary 607
Chapter 36: WCF and WF Applications 609
Windows Communication Foundation 609Consuming a WCF Service 615
Windows Workflow Foundation 617Summary 623
Chapter 37: Next Generation Web: Silverlight and ASP.NET MVC 625
Silverlight 626Getting Started with Silverlight 2 627Interacting with Your Web Page 631Hosting Silverlight Applications 633
ASP.NET MVC 634Model-View-Controller 635Getting Started with ASP.NET MVC 636Controllers and Action Methods 638Rendering a UI with Views 641Custom URL Routing 644
Summary 645
Part VIII: Configuration and Internationalization 647
Chapter 38: Configuration Files 649
Config Files 649Machine.Config 649Web.Config 649App.Config 650Security.Config 650
Configuration Schema 651Section: configurationSections 651Section: startup 652
ftoc.indd xxviiftoc.indd xxvii 6/24/08 12:21:45 AM6/24/08 12:21:45 AM
Contents
xxviii
Section: runtime 652Section: system.runtime.remoting 653Section: system.net 653Section: cryptographySettings 654Section: system.diagnostics 654Section: system.web 655Section: webserver 655Section: compiler 656Configuration Attributes 656
Application Settings 657Using appSettings 657Project Settings 658Dynamic Properties 659Custom Configuration Sections 660
Referenced Projects with Settings 664Summary 665
Chapter 39: Connection Strings 667
Connection String Wizard 667SQL Server Format 672In-Code Construction 673Encrypting Connection Strings 674Summary 676
Chapter 40: Resource Files 677
What Are Resources? 677Text File Resources 677Resx Resource Files 679Binary Resources 680Adding Resources 680Embedding Files as Resources 681Naming Resources 681Accessing Resources 682Designer Files 682
Resourcing Your Application 683Control Images 685
Satellite Resources 686Cultures 686Creating Culture Resources 686Loading Culture Resource Files 687Satellite Culture Resources 688
ftoc.indd xxviiiftoc.indd xxviii 6/24/08 12:21:45 AM6/24/08 12:21:45 AM