Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com PROFESSIONAL VISUAL BASIC® 2010 AND .NET 4 INTRODUCTION xxxv PART I LANGUAGE CONSTRUCTS AND ENVIRONMENT CHAPTER 1 Visual Studio 2010 3 CHAPTER 2 Objects and Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 CHAPTER 3 Custom Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137 CHAPTER 4 The Common Language Runtime 211 CHAPTER 5 Declarative Programming with Visual Basic . . . . . . . . . . . . . . . . . . . . . . 253 CHAPTER 6 Exception Handling and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 CHAPTER 7 Test-Driven Development 287 PART II BUSINESS OBJECTS AND DATA ACCESS CHAPTER 8 Arrays, Collections, and Generics 311 CHAPTER 9 Using XML with Visual Basic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 CHAPTER 10 ADO.NET and LINQ 389 CHAPTER 11 Data Access with the Entity Framework . . . . . . . . . . . . . . . . . . . . . . . . . 437 CHAPTER 12 Working with SQL Server 457 CHAPTER 13 Services (XML/WCF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 PART III SMART CLIENT APPLICATIONS CHAPTER 14 Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541 CHAPTER 15 Advanced Windows Forms 575 CHAPTER 16 User Controls Combining WPF and Windows Forms . . . . . . . . . . . . . . 599 CHAPTER 17 WPF Desktop Applications 617 CHAPTER 18 Expression Blend 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667 CHAPTER 19 Silverlight 679 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com PART IV INTERNET APPLICATIONS CHAPTER 20 Silverlight and Services 699 CHAPTER 21 Working with ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 CHAPTER 22 ASP.NET Advanced Features 751 CHAPTER 23 ASP.NET MVC 787 CHAPTER 24 SharePoint 2010 Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807 PART V LIBRARIES AND SPECIALIZED TOPICS CHAPTER 25 Visual Studio Tools for Oce 843 CHAPTER 26 Windows Workflow Foundation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881 CHAPTER 27 Localization 905 CHAPTER 28 COM-Interop 929 CHAPTER 29 Network Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 949 CHAPTER 30 Application Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981 CHAPTER 31 Assemblies and Reflection 1001 CHAPTER 32 Security in the .NET Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1021 CHAPTER 33 Parallel Programming Using Tasks and Threads . . . . . . . . . . . . . . . . . .1051 CHAPTER 34 Deployment 1101 APPENDIX A The Visual Basic Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1137 APPENDIX B Visual Basic Power Packs Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1151 APPENDIX C Workflow 2008 Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1165 APPENDIX D Enterprise Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1185 APPENDIX E Programming for the Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1205 INDEX 1233 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com PROFESSIONAL Visual Basic® 2010 and .NET 4 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com PROFESSIONAL Visual Basic® 2010 and .NET 4 Bill Sheldon Billy Hollis Kent Sharkey Jonathan Marbutt Rob Windsor Gastón C. Hillar Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Professional Visual Basic® 2010 and .NET 4 Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-50224-2 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and 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 Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2010921246 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 Basic 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. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com To my wonderful wife, Tracie, who is forced to carry on while I isolate myself to concentrate on writing. And to the next generation of children who have joined our extended Sheldon family (my own and my brothers’) in the past five years — Nick, Elena, Ben, Billy V, Abigail, and Johnny — each and every one of you is a valuable part of our lives. —Bill Sheldon I owe tremendous thanks to my family, who have somehow learned to put up with marathon writing sessions, and to my business partner, Gary Bailey, for keeping our clients happy while I’m writing. —Billy Hollis To Babi, for keeping me alive and putting up with me — hopefully, for a long time to come. —Kent Sharkey To my beautiful wife, Jennifer, who was my greatest encouragement despite the long days of writing and working. And to my loving daughter, Kathryn, who always managed to put a smile on my face after a long day. —Jonathan Marbutt To my Dad, who did not complain too much about the weekends I spent writing instead of playing golf with him. —Rob Windsor To my son, Kevin —Gastón Hillar Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com [...]... How Deep to Go? Summary Chapter 4: The common language runtime Elements of a NET Application Modules Assemblies Types 1 14 1 14 11 5 11 6 11 7 11 9 11 9 12 0 12 1 12 3 1 24 12 8 13 0 1 34 13 5 13 6 13 7 13 8 13 9 15 9 1 64 17 5 17 7 17 7 17 8 1 84 18 7 18 9 18 9 19 8 19 8 205 208 211 212 212 213 2 14 xvii Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CONTENTS Versioning and Deployment Better Support for... Data Using LINQ to SQL: Creating the Console Application Introducing the O/R Designer Creating the Product Object 385 387 389 390 3 91 3 91 395 396 398 398 399 399 40 2 40 4 40 6 40 9 40 9 41 0 41 0 41 0 41 1 41 1 41 3 41 4 41 6 41 8 41 8 41 9 42 1 42 1 42 2 42 2 42 3 42 4 xxi Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CONTENTS How Objects Map to LINQ Objects The DataContext Object The Table(TEntity)... 10 16 10 16 10 17 10 18 10 19 10 21 1022 10 23 10 26 10 26 10 27 10 29 10 32 10 33 10 34 10 35 10 36 10 37 1 049 10 51 10 51 1052 10 52 10 57 10 57 10 60 10 61 1062 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CONTENTS Parallel.For Parallel.ForEach Exiting from Parallel Loops Specifying the Desired Degree of Parallelism ParallelOptions Understanding Hardware Threads and Logical Cores Creating and. .. Visual Studio Deployment Projects Project Templates Creating a Deployment Project Modifying the Deployment Project Project Properties The File System Editor The Registry Editor The File Types Editor The User Interface Editor The Custom Actions Editor The Launch Conditions Editor Building Internet Deployment of Windows Applications 11 02 11 02 11 02 11 03 11 03 11 03 11 04 11 05 11 09 11 09 11 11 111 5 11 17 11 18... Chapter 11 : Data Access with the Entity Framework Object-Relational Mapping Entity Framework Architecture Conceptual Model Storage Model Mapping Model LINQ to Entities The ObjectContext Mapping Objects to Entities 42 5 42 6 42 8 42 8 42 9 42 9 42 9 43 0 43 1 43 2 43 3 43 5 43 7 43 8 43 8 43 9 44 2 44 3 44 3 44 5 44 6 Simple Mapping Using a Single Table for Multiple Objects Using Multiple Tables for an Object 44 6 44 8 45 0 Generating... 11 11 111 5 11 17 11 18 11 20 11 22 11 24 11 24 No-Touch Deployment ClickOnce Deployment 11 25 11 26 IIS Web Deployment Tool Summary 11 33 11 35 xxxiii Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CONTENTS Appendix A: The Visual Basic Compiler Appendix B: Visual Basic Power Packs Tools 11 51 Appendix C: Workflow 2008 Specifics 11 65 Appendix D: Enterprise Services 11 85 Appendix E: Programming... Differences in Numbers and Currencies Understanding Differences in Sorting 843 844 844 844 845 846 847 852 8 54 856 859 862 8 64 8 71 880 8 81 8 81 882 882 8 84 887 889 896 899 900 903 905 905 906 907 908 909 910 910 913 915 xxix Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CONTENTS ASP.NET Resource Files 916 Making Use of Local Resources Global Resources 916 9 21 Resource Files in... Toolbars and the ToolStrip Control Menus Common Dialogs Drag and Drop Summary of Standard Windows.Forms Controls Handling Groups of Related Controls Adding Controls at Runtime Other Handy Programming Tips Summary Chapter 15 : Advanced Windows Forms 543 543 543 544 544 544 545 547 547 547 548 549 550 5 51 552 552 552 553 555 556 556 557 559 5 61 562 5 64 566 568 569 5 71 572 573 573 575 Packaging Logic in Visual. .. System.Threading.Tasks.Task Understanding a Task’s Life Cycle Using Tasks to Parallelize Code Returning Values from Tasks Preparing the Code for Concurrency and Parallelism Understanding Concurrent Collection Features Transforming LINQ into PLINQ Summary 10 62 10 67 10 72 10 76 10 77 10 78 10 79 10 80 10 81 1082 10 90 10 93 10 94 10 97 10 99 Chapter 34: Deployment 11 01 Application Deployment 11 02 Why Deployment Is Straightforward... in Code Additional Components for Visual Studio 3 4 7 10 11 14 15 16 17 21 22 24 25 28 28 31 39 Enhancing a Sample Application 40 Customizing the Code Building Applications Reusing Your First Windows Form 41 45 52 Useful Features of Visual Studio 2 010 Build Configurations The Task List The Command Window Server Explorer Recording and Using Macros in Visual Studio 2 010 Class Diagrams Application Lifecycle . Events 1 14 Declaring and Raising Custom Events 11 5 Receiving Events with WithEvents 11 6 Receiving Events with AddHandler 11 7 Constructor Methods 11 9 Termination and Cleanup 11 9 Advanced Concepts 12 0 Overloading. ENVIRONMENT CHAPTER 1: VISUAL STUDIO 2 010 3 Visual Studio 2 010 : Express through Ultimate 4 Visual Basic Keywords and Syntax 7 Console Applications 10 Creating a Project from a Project Template 11 The Solution. Classes 10 3 Basic Classes 10 3 Handling Events 11 3 Handling Multiple Events 11 3 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com CONTENTS xvii The WithEvents Keyword 1 14 Raising