1. Trang chủ
  2. » Công Nghệ Thông Tin

70-536 microsoft .net framework 2.0 application development foundation

1,1K 556 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.078
Dung lượng 6,22 MB

Nội dung

70-536 microsoft .net framework 2.0 application development foundation

PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2006 by Tony Northrup, Shawn Wildermuth, Bill Ryan, and GrandMasters, LLC All rights reserved No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher ISBN-13: 978-0-7356-2277-7 ISBN-10: 0-7356-2277-9 Library of Congress Control Number 2006924468 Printed and bound in the United States of America QWT Distributed in Canada by H.B Fenn and Company Ltd A CIP catalogue record for this book is available from the British Library Microsoft Press books are available through booksellers and distributors worldwide For further information about international editions, contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329 Visit our Web site at www.microsoft.com/mspress Send comments to tkinput@microsoft.com Microsoft, Active Directory, Excel, IntelliSense, Internet Explorer, Microsoft Press, MSDN, OpenType, Outlook, Visual Basic, Visual C#, Visual Studio, Win32, Windows, Windows Server, and Windows Vista are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries Other product and company names mentioned herein may be the trademarks of their respective owners The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred This book expresses the author’s views and opinions The information contained in this book is provided without any express, statutory, or implied warranties Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book Acquisitions Editor: Ken Jones Project Editor: Laura Sackerman Technical Editors: Jim Fuchs and David Robinson Indexers: Lee Ross and Tony Ross Body Part No X12-41817 For Sandi Edson —Tony Northrup To my mother, Pennie Wildermuth —Shawn Wildermuth To my parents, Walter and Carole Converse, for always being there for me To Kim and Sarah Finleyson for putting up with me always being busy and keeping me smiling Finally, to Walter Bellhaven and Herb Sewell, for helping me maintain my sanity for the past year —Bill Ryan About the Authors Tony Northrup In the mid 1980s, Tony Northrup, CISPP, MCSE, and MVP, learned to program in BASIC on a ZX-81 personal computer built from a kit Later, he mastered the 68000 assembly and ANSI C on the Motorola VERSAdos operating system before beginning to write code for MS-DOS After a brief time with the NEXTSTEP operating system, Tony returned to a Microsoft platform because he was impressed by the beta version of Microsoft Windows NT 3.1 Although he has dabbled in other operating systems, Tony has since focused on Windows development in Microsoft Visual C++, Visual Basic, C#, and Perl (for automation projects) Tony now develops almost exclusively for the NET Framework Tony started writing in 1997 and has since published more than a dozen technology books on the topics of development and networking In addition, Tony has written dozens of articles at http://www.microsoft.com, covering topics ranging from securing ASP.NET applications, to designing firewalls to protect networks and computers Tony spends his spare time hiking through the woods near his Phillipston, Massachusetts home He’s rarely without his camera, and in the past six years has created what might be the largest and most popular publicly accessible database of nature and wildlife photographs on the Internet Tony lives with his wife Erica and his cat (also his favorite photographic subject) Sammy Shawn Wildermuth Shawn Wildermuth is a Microsoft C# MVP and is the founder of Wildermuth Consulting Services, LLC, a company that is dedicated to delivering software and training solutions in the Atlanta, Georgia area He is also a speaker on the INETA Speaker Bureau and has appeared at several national conferences to speak on a variety of subjects Shawn is also the author of the book Pragmatic ADO.NET as well as the upcoming Prescriptive Data Architectures, both for Addison-Wesley He has been writing articles for a number of years for a variety of magazines and Web sites, including MSDN, MSDN Online, DevSource, InformIT, Windows IT Pro, The ServerSide NET, ONDotNet.com, and Intel’s Rich Client Series Shawn has enjoyed building data-driven software for more than 20 years Bill Ryan Bill Ryan is a Senior Software Developer at InfoPro, Inc., a large medical records management company in Augusta, GA Bill is a Microsoft MVP in the Windows Embedded category Bill is also the co-author of Professional ADO.NET and Professional WinFX Beta, both by Wrox Press He’s currently authoring Professional Microsoft Speech Server by Apress Bill is a frequent speaker at events such as Microsoft Code Camps, Speech Server Days, and NET User’s Groups He also runs two NET focused Web sites, www.devbuzz.com and www.knowdotnet.com Contents at a Glance Framework Fundamentals Input/Output (I/O) 67 Searching, Modifying, and Encoding Text 143 Collections and Generics 185 Serialization 267 Graphics 319 Threading 367 Application Domains and Services 435 Installing and Configuring Applications 477 10 Instrumentation 551 11 Application Security 627 12 User and Data Security 701 13 Interoperation 783 14 Reflection 829 15 Mail 889 16 Globalization 919 vii Table of Contents Introduction xxxi Hardware Requirements xxxi Software Requirements xxxii Using the CD and DVD xxxii How to Install the Practice Tests xxxiii How to Use the Practice Tests xxxiii How to Uninstall the Practice Tests xxxiv Microsoft Certified Professional Program xxxv Technical Support xxxv Evaluation Edition Software Support xxxvi Framework Fundamentals Before You Begin Lesson 1: Using Value Types Built-in Value Types How to Declare Value Types How to Create User-Defined Types How to Create Enumerations 10 Lab: Declaring and Using Value Types 11 Lesson Summary 14 Lesson Review 15 Lesson 2: Using Common Reference Types 17 What Is a Reference Type? 17 Comparing the Behavior of Reference and Value Types 17 Built-in Reference Types 19 Strings and String Builders 19 How to Create and Sort Arrays 21 How to Use Streams 22 How to Throw and Catch Exceptions 23 Lab: Working with Reference Types 25 Lesson Summary 30 Lesson Review 30 What you think of this book? We want to hear from you! Microsoft is interested in hearing your feedback about this publication so we can continually improve our books and learning resources for you To participate in a brief online survey, please visit: www.microsoft.com/learning/booksurvey/ ix x Contents Lesson 3: Constructing Classes What Is Inheritance? What Is an Interface? What Are Partial Classes? What Are Generics? Events What Are Attributes? What Is Type Forwarding? Lab: Create a Derived Class with Delegates Lesson Summary Lesson Review Lesson 4: Converting Between Types Conversion in Visual Basic and C# What Is Boxing and Unboxing? How to Implement Conversion in Custom Types Lab: Safely Performing Conversions Lesson Summary Lesson Review Chapter Review Chapter Summary Key Terms Case Scenario Case Scenario: Designing an Application Suggested Practices Manage Data in a NET Framework Application by Using NET Framework 2.0 System Types Implement NET Framework Interfaces to Cause Components to Comply with Standard Contracts Control Interactions Between NET Framework Application Components by Using Events and Delegates Take a Practice Test 32 32 34 38 38 44 47 48 49 52 52 54 54 56 56 59 60 61 62 62 63 63 64 64 64 65 65 65 Input/Output (I/O) 67 Before You Begin Lesson 1: Navigating the File System What Are the File System Classes? The FileSystemInfo Class The FileInfo Class How to Get Information about a File How to Copy a File 68 69 69 69 70 72 72 1028 Interlocked class interfaces, continued IConfigurationSystem, 543 IEqualityComparer, 215–217 IIdentity, 716–720 IPrincipal, 720–721 Interlocked class, 389–391 interoperation COM objects See COM objects exposing NET components See exposing NET components to COM key terms, 825–826 overview, 783–784 practice tests, 828 prerequisites, 785 review, 825 scenario for incorporating legacy code, 826–827 suggested practices, 828 summary, 825 unmanaged code See unmanaged code introduction, xxxi invariant cultures, 921 IPrincipal interface, 720–721 ISO 8859, 172 isolated storage creating stores, 127–128 IsolatedStorageFile class, 126–127 IsolatedStorageFilePermission class, 134 IsolatedStorageFileStream class, 129–130 lab for creating files, 135–136 lab for reading files, 136–137 lab overview, 135 overview, 125 permissions, 134–135 reading and writing data, 131–132 review, 137–138 summary, 137 using directories, 133–134 IsolatedStorageFile class, 126–127 IsolatedStorageFilePermission class, 134 K key terms application domains, 472–473 application security, 696–697 collections, 262 configuring applications, 548 creating applications, 548 data security, 777–778 e-mail, 915 fundamentals, 63 globalization, 942 graphics, 362 input/output (I/O), 139–140 instrumentation, 624–625 interoperation, 825–826 mail, 915 NET Framework fundamentals, 63 reflection, 886 serialization, 313–314 text processing, 180 threading, 431–432 user security, 777–778 Windows services, 472–473 L labs adding copyright notices to pictures, 354–356 adding enumeration to structures, 13–14 adding legends to pie charts, 356–359 adding role-based security to applications, 725–729 building COM-enabled assemblies, 803–805 building FIFO and LIFO lists, 205–207 calling Windows DLL functions, 822–823 case-insensitive, localizable lookup tables, 238–239 changing and restoring application settings, 529 compiling and testing permissions of sample assemblies, 653 compressing existing files, 121–122 converting text files to different encoding types, 177 creating application event logs, 561, 589–590 creating code groups and permission sets, 654–655 creating dynamic assemblies, 882–884 creating files in isolated storage, 135–136 creating generic collections, 259–260 creating lookup tables, 223–224 creating MailMessage objects, 897–899 creating single-instance applications using Mutex, 408–410 creating SmtpClient objects to send MailMessage objects, 907–910 creating structures, 11–13 creating Windows service installers, 468–469 creating Windows services to monitor Web sites, 465–468 creating your own culture, 938–939 declarative security requirements, 666–667 demonstrating multithreading, 383 deriving new class from existing class, 49–50 deserializing objects, 283–284 distinguishing between phone numbers and ZIP Codes, 163–165 drawing pie charts, 334–337 enabling option strict (Visual Basic), 60 encrypting and decrypting files, 770–774 enumerating through files in folders, 83–84 examining assemblies, 838–840 examining implicit conversions, 59–60 experimenting with default permission sets, 687–689 getting database connection strings, 503–509 managing configurations granting access to partially trusted code, 691–694 identifying types as value or reference, 26–27 improving appearance of pie charts, 337–339 installing and managing Windows services, 469 invoking members through reflection, 872–874 loading assemblies and dumping type information, 864–866 loading assemblies by assembly name, 445 loading assemblies by filename, 444–445 loading assemblies with restricted privileges, 453–454 making classes serializable, 281–282 modifying code groups with Caspol, 655 monitoring application performance, 611–613 optimizing classes for deserialization, 284–285 queuing work items using ThreadPool, 428–429 reading and writing configuration settings, 543–545 reading files, 112 reading files in isolated storage, 136–137 reformatting strings, 165–166 replacing binary serialization with XML serialization, 297–299 responding to events, 50–52 restricting permissions to My_Computer_Zone, 689– 690 saving pie charts as pictures, 345–346 sending e-mail asynchronously, 910–912 serializing objects, 282–283 setting and displaying assembly attributes at runtime, 848–850 setting and rolling back registry keys, 518–519 sorting table of strings, 197–198 uncompressing new files, 122–123 updating classes to use custom serialization, 309–311 using COM applications from NET, 794–795 watching for changes in file system, 84–86 working with DACLs and inheritance, 739–740 working with strings and arrays, 27–28 working with strings and exceptions, 28–30 writing code that adjusts to culture, 932–934 writing network events to logs, 621–623 writing to new files, 111–112 lesson review options, xxxiii–xxxiv lines, drawing, 326–329 ListDictionary class, 220 listeners DefaultTraceListener class, 584–585 DelimitedListTraceListener class, 588 EventLogTraceListener class, 588 listener objects overview, 584 TextWriterTraceListener class, 585–586 Trace class, 582–583 trace overview, 581 TraceSource class, 583 TraceSwitch class, 583 XmlWriterTraceListener class, 586–588 1029 lists, sequential lab for creating queues, 205–206 lab for creating stacks, 207 lab overview, 205 overview, 201 Queue class, 201–203 review, 208 Stack class, 203–205 summary, 207–208 logging events avoiding EventLog objects in partial trust environments, 555 creating event logs, 555–556 deleting event logs, 556 lab for creating application event logs, 561 overview, 553 reading from event logs, 559–560 review, 562–563 SQL injection attacks, 558 summary, 562 using Windows events, 553–555 writing to event logs, 556–559 M mail creating messages See creating mail messages key terms, 915 overview, 889 practice tests, 917–918 prerequisites, 890 review, 915 scenario for adding capabilities to applications, 915–916 sending messages See sending mail messages suggested practices, 916–917 summary, 915 System.Net.Mail namespace, 889 management events enumerating logical drives, 617 enumerating management objects, 616–617 enumerating network adapters, 618 lab for writing network events to logs, 621–623 ManagementEventWatcher class, 620 overview, 616 retrieving information about services that are paused, 619–620 review, 623 subscribing to, 620 summary, 623 System.Management namespace, 616–617 ManagementEventWatcher class, 620 managing configurations adding multiple sections to configuration files, 534 ConfigurationManager object, 532–534 ConfigurationManager's GetSection method, 538 1030 MemoryStream class managing configurations, continued ConfigurationSection class, 534 creating custom sections in configuration files, 539 creating SectionGroup object, 534 getting and storing settings, 532–534 IApplicationSettingsProvider interface, 541–543 IConfigurationSectionHandler interface, 534, 536 IConfigurationSystem interface, 543 implementing configuration interfaces, 534 implementing custom sections in configuration files, 539 interfaces for System.Configuration class, 534 lab for reading and writing configuration settings, 543–545 managing ConfigurationSectionGroup object, 535–536 overview, 532 review, 546 summary, 545–546 using attribute-based values, 538 MemoryStream class, 105–108 methods Assert, 568–571 compression, 114 ConfigurationManager's GetSection, 538 DEFLATE vs GZIP, 114 Flush, 573 Join, 375–376 obsolete, 488 Print, 572–573 protecting See protecting methods using declarative and imperative security Write, 571 WriteIf, 571–572 WriteLine, 572 WriteLineIf, 572 Microsoft certifications, xxxv modifying text See processing text Monitor class, 394–395 monitoring performance CounterCreationData class, 601–602 enumerating processes, 595–598 lab for monitoring application performance, 611–613 overview, 593 overview of processes, 595–596 performance counters, 599–601 PerformanceCounter class, 604–605 PerformanceCounterCategory class, 602–604 Process class, 595 review, 614–615 StackFrame class, 609–611 StackTrace class, 609–611 starting processes, 605 starting processes with command-line arguments, 607–608 starting processes without command-line arguments, 605–607 summary, 613–614 Mutex class, 403–405 N NameValueCollection class, 235–237 navigating file system changing file extensions, 78 classes overview, 69 copying files, 72–73 DirectoryInfo class, 73 DriveInfo class, 74–75 DriveType enumeration, 75–76 enumerating drives, 76 enumerating files in directories, 74 FileInfo class, 70–71 FileSystemInfo class, 69–70 FileSystemWatcher class, 78–79 lab for enumerating through files in folders, 83–84 lab for watching for changes, 84–86 lab overview, 83 monitoring directory for changes, 80–82 obtaining information about specific files, 72 overview, 69 Path class, 77 review, 86–87 summary, 86 NET Framework 2.0 Configuration tool browsing configurations, 521–523 changing configurations, 523–528 configuring CAS See configuring CAS with NET Framework Configuration tool lab for changing and restoring application settings, 529 overview, 521 review, 531 summary, 530 NET Framework fundamentals common reference types See common reference types constructing classes See constructing classes converting between types See converting between types key terms, 63 overview, practice tests, 65–66 prerequisites, review, 62 scenario for designing applications, 64 suggested practices, 64–65 summary, 62–63 value types See value types neutral cultures, 921 NumberFormatInfo class, 927–929 practice tests O object serialization See also XML serialization BinaryFormatter, 279 controlling SOAP serialization, 280–281 creating classes, 274–275 custom serialization See custom serialization deserialization, 272–274 disabling serialization of specific members, 275–277 formats, 279 guidelines, 281 lab for deserializing objects, 283–284 lab for making classes serializable, 281–282 lab for optimizing classes for deserialization, 284– 285 lab for serializing objects, 282–283 lab overview, 281 overview, 269–270 review, 286–287 security concerns, 275 SoapFormatter, 279–280 steps for, 270–271 summary, 285–286 version compatibility, 277–279 OrderedDictionary class, 222–223 overview, xxxi P partial classes, 38 Path class, 77 pattern matching in regular expressions extracting matched data, 158–159 matching simple text, 148 matching special characters, 150–151 matching text in specific locations, 148–150 matching text using wildcards, 151–154 matching using backreferences, 154–155 overview, 145–148 specifying options, 155–158 pens, customizing, 330–332 performance counters, 599–601 performance monitoring CounterCreationData class, 601–602 enumerating processes, 595–598 lab for monitoring application performance, 611–613 overview, 593 overview of processes, 595–596 performance counters, 599–601 PerformanceCounter class, 604–605 PerformanceCounterCategory class, 602–604 Process class, 595 review, 614–615 StackFrame class, 609–611 StackTrace class, 609–611 starting processes, 605 1031 starting processes with command-line arguments, 607–608 starting processes without command-line arguments, 605–607 summary, 613–614 PerformanceCounter class, 604–605 PerformanceCounterCategory class, 602–604 permission sets, 635–636, 643, 686–687 permissions analyzing granted, 679 assembly declaration types, 662–663 classes for CAS, 659–662 code access security (CAS), 632–635 compiling and testing for assemblies, 653 declaratively demanding CAS, 676–677 declaratively limiting, 680–681 demanding, 674–675 determining for assemblies, 643 explicit, 732 handling errors, 681–682 imperatively demanding CAS, 678–679 imperatively limiting, 681 inherited, 733 lab for restricting permissions to My_Computer_Zone, 689–690 limiting techniques, 680 method permission request guidelines, 673–674 relaxing to improve performance, 682–686 suggested practices for controlling, 699 pictures creating and saving, 343–345 displaying, 343 pie charts adding legends, 356–359 creating methods overview, 334 drawing, 334–337 improving appearance, 337–339 lab for saving pie charts as pictures, 345–346 Platform Invoke (P/Invoke), 807–809 polling model, 416–417 practice tests application domains, 476 application security, 700 collections, 265–266 compared to lesson reviews, xxxiii configuring applications, 550 data security, 782 e-mail, 917–918 globalization, 944 graphics, 366 input/output (I/O), 142 installing, xxxiii installing applications, 550 instrumentation, 626 interoperation, 828 1032 PrincipalPermission class practice tests, continued mail, 917–918 options, xxxiv overview, xxxii reflection, 888 serialization, 317 text processing, 183 threading, 434 types, 65–66 uninstalling, xxxiv user security, 782 using, xxxiii Windows services, 476 PrincipalPermission class, 710–711 Print method, 572–573 Process class, 595 processes compared to application domains, 438 enumerating, 595–598 overview, 595–596 Process class, 595 starting, 605 starting with command-line arguments, 607–608 starting without command-line arguments, 605–607 processing text encoding and decoding See encoding and decoding text forming regular expressions See forming regular expressions key terms, 180 overview, 143 practice tests, 183 prerequisites, 144 review, 180 scenario for processing data from legacy computers, 182 scenario for validating input, 181 suggested practices, 182–183 summary, 180 protecting assemblies using declarative security assembly declaration guidelines, 666 assembly permission declaration types, 662–663 classes for CAS permissions, 659–662 creating assembly declarations, 663–665 lab for declarative security requirements, 666–667 overview, 658 reasons to use CAS assembly declarations, 658–659 review, 668–671 summary, 667–668 protecting methods using declarative and imperative security analyzing granted permissions, 679 calling trusted code from partially trusted code, 686 declaratively demanding CAS permissions, 676–677 declaratively limiting method permissions, 680–681 demanding permissions, 674–675 handling permission errors, 681–682 imperatively demanding CAS permissions, 678–679 imperatively limiting permissions, 681 lab for experimenting with default permission sets, 687–689 lab for granting access to partially trusted code, 691–694 lab for restricting permissions to My_Computer_Zone, 689–690 lab overview, 687 limiting permissions, 680 method permission request guidelines, 673–674 method permission request types, 672–673 overview of protecting methods, 668–671 permission sets, 686–687 relaxing permissions to improve performance, 682–686 security risks of declarative demands, 674 Q-R Queue class, 201–203 raising events, 46 RCW (Runtime Callable Wrapper), 786 ReaderWriterLock class, 398–402 reading and writing files BufferedStream class, 108–110 classes that facilitate, 90–91 Directory class, 92–93 File class, 91–92 FileAccess enumeration, 94 FileMode enumeration, 94 FileStream class, 95–96 lab for reading files, 112 lab for writing to new files, 111–112 lab overview, 111 lesson review, 113 lesson summary, 112–113 MemoryStream class, 105–108 overview, 88 readers, 102–104 reading files, 97–99 StreamReader class, 97 streams, 88–90 StreamWriter class, 100 writers, 102–104 writing to files, 100–102 reference types built-in, 19 compared to value types, 17–18 creating arrays, 21 garbage collection, 17 lab for identifying types as value or reference, 26–27 lab for working with strings and arrays, 27–28 lab for working with strings and exceptions, 28–30 sending mail messages lab overview, 25 overview, 17 review, 30–31 strings and string builders, 19–21 summary, 30, 62 throwing exceptions, 23–25 using streams, 22–23 reflecting types BindingFlags enumeration, 863 enumerating class members, 859–861 getting, 852–857 lab for loading assemblies and dumping type information, 864–866 MethodBody object, 861–862 objects, 857–859 overview, 852 review, 867 summary, 866 reflection assemblies, 831–832 assembly attributes See assembly attributes Assembly class, 833–838 creating code at runtime See creating code at runtime dynamic code See dynamic code key terms, 886 lab for examining assemblies, 838–840 modules, 833 overview, 829 practice tests, 888 prerequisites, 830–831 reflecting types See reflecting types review, 840–841, 886 scenario for creating plugin architecture, 887 scenario for writing assembly explorer applications, 887–888 summary, 840, 886 RegionInfo class, 926–927 regular expressions constraining string input, 161–162 extracting matched data, 158–159 lab for distinguishing between phone numbers and ZIP Codes, 163–165 lab for reformatting strings, 165–166 lab overview, 163 matching simple text, 148 matching special characters, 150–151 matching text in specific locations, 148–150 matching text using wildcards, 151–154 matching using backreferences, 154–155 overview, 145 pattern matching overview, 145–148 replacing substrings, 160–161 review, 167–170 specifying options, 155–158 summary, 166 1033 requirements hardware, xxxi–xxxii software, xxxii responding to events, 45–46 Runtime Callable Wrapper (RCW), 786 S SACL (security access control list), 735–736 scenarios adding e-mail capabilities to existing applications, 915–916 choosing graphics techniques, 363 choosing serialization techniques, 314 choosing where to direct output, 625 creating custom authentication methods, 778–780 creating plugin architecture, 887 creating simple charts, 364 creating testing tools, 473–474 customizing CAS, 698 designing applications, 64 explaining CAS, 697 improving server processing, 432 incorporating legacy code, 826–827 installing and configuring applications, 548–549, 942–943 monitoring files, 474–475 monitoring old servers, 140–141 multiple applications, 432–433 processing data from legacy computers, 182 protecting data using cryptography, 780 rewriting to use type-safe collections, 264 saving user settings, 140 selecting collections, 263 serializing between versions, 315 using ArrayList to store status codes, 263 validating input, 181 searching text See processing text security application See application security data See data security declarative See declarative security imperative See imperative security user See user security security access control list (SACL), 735–736 security policies, 639–640 Semaphore class, 405–406 sending mail messages asynchronously, 905–907 configuring credentials, 904–905 configuring SSL, 905 handling exceptions, 903–904 lab for creating SmtpClient objects to send MailMessage objects, 907–910 lab for sending e-mail asynchronously, 910–912 lab overview, 907 1034 sequential lists sending mail messages, continued overview, 902 review, 913–914 SMTP servers, 902–903 summary, 912–913 sequential lists lab for creating queues, 205–206 lab for creating stacks, 207 lab overview, 205 overview, 201 Queue class, 201–203 review, 208 Stack class, 203–205 summary, 207–208 serialization custom serialization See custom serialization key terms, 313–314 overview, 267–268 practice tests, 317 prerequisites, 268 review, 313 scenario for choosing serialization techniques, 314 scenario for serializing between versions, 315 serializing objects See serializing objects suggested practices for controlling serialization of objects, 316 suggested practices for implementing custom serialization formatting, 316 suggested practices for using runtime serialization techniques, 315–316 summary, 313 XML See XML serialization serializing objects See also XML serialization BinaryFormatter, 279 controlling SOAP serialization, 280–281 creating classes, 274–275 deserialization, 272–274 disabling serialization of specific members, 275–277 formats, 279 guidelines, 281 lab for deserializing objects, 283–284 lab for making classes serializable, 281–282 lab for optimizing classes for deserialization, 284–285 lab for serializing objects, 282–283 lab overview, 281 overview, 269–270 review, 286–287 security concerns, 275 SoapFormatter, 279–280 steps for, 270–271 summary, 285–286 version compatibility, 277–279 services, Windows building setup projects, 462–463 compared to other projects, 458–459 controlling, 463–465 creating in Visual Studio, 457 creating install projects, 461–462 creating projects, 459–460 implementing, 460 installing manually, 462 key terms, 472–473 lab for creating service installers, 468–469 lab for creating services to monitor Web sites, 465–468 lab for installing and managing, 469 lab overview, 465 managing, 463–465 monitoring files, 474–475 overview, 435, 457 practice tests, 476 prerequisites, 436 review, 470–472 suggested practices, 476 summary, 469–470, 472 shapes drawing, 326–329 filling, 332–334 sharing data between threads avoiding collisions, 387–391 Counter class, 391–393 deadlocks, 396–398 Event class, 406–407 Interlocked class, 389–391 lab for creating single-instance applications using Mutex, 408–410 Monitor class, 394–395 Mutex class, 403–405 overview, 387 ReaderWriterLock class, 398–402 review, 410–411 Semaphore class, 405–406 summary, 410 synchronization locks overview, 391–395 synchronization with Windows kernel objects, 402–403 thread synchronization, 391 volatile data, 390 WaitHandle class, 403 software requirements, xxxii SortedList class, 218–220 specialized collections binary math, 230 BitArray class, 226–227 bits overview, 226 BitVector32 for bit masks, 228–229 BitVector32 for bit packing, 230–232 case-insensitive collections, 234 collecting strings overview, 232 terms culture-invariant collections, 235 lab for creating ListCollection for lookup tables, 238–239 NameValueCollection class, 235–237 overview, 226 review, 239–240 StringCollection class, 232–233 StringDictionary class, 233–234 summary, 239 specialized dictionaries HybridDictionary class, 221 ListDictionary, 220 OrderedDictionary class, 222–223 overview, 220 specific cultures, 921 SQL injection attacks, 558 Stack class, 203–205 StackFrame class, 609–611 StackTrace class, 609–611 StreamReader class, 97 streams compressing See compressing streams reading and writing files, 88–90 using, 22–23 StreamWriter class, 100 StringCollection class, 232–233 StringDictionary class, 233–234 strings case-insensitive collections, 234 collecting overview, 232 culture-invariant collections, 235 reference types, 19–21 StringCollection class, 232–233 StringDictionary class, 233–234 suggested practices accessing and modifying identity information, 781 application domains, 475 comparing Dictionary classes, 265 configuring applications, 549–550 controlling code privileges with System.Security.Policy classes, 699 controlling interactions using events and delegates, 65 controlling permissions with System.Security.Permission classes, 699 controlling serialization of objects using System.Xml.Serialization namespace, 316 creating custom cultures, 943 creating file searcher applications, 141 creating simple configuration storage, 141 creating ThreadPool applications, 433–434 e-mail, 916–917 embedding configuration, diagnostic, management, and installation features, 626 encrypting, decrypting, and hashing data, 782 1035 enhancing user interface using brushes, pens, colors, and fonts, 365 enhancing user interface using graphics, images, bitmaps, and icons, 365 enhancing user interface using shapes and sizes, 365–366 handling permission errors, 681–682 implementing access control, 781–782 implementing CAS to improve security, 698–699 implementing custom authentication schemes, 781 implementing custom serialization formatting, 316 implementing interfaces to comply with standard contracts, 65 installing applications, 549–550 interoperation, 828 mail, 916–917 managing data using types, 64–65 serializing objects using runtime serialization techniques, 315–316 text processing, 182–183 using culture information, 943 using generic collections, 264–265 version compatibility in serialization, 278–279 Windows services, 476 writing assembly explorer applications, 887–888 support evaluation edition software, xxxvi technical, xxxv symmetric keys encrypting and decrypting messages, 751–753 encryption, 744–746 establishing, 749–750 overview, 743–744 symmetric algorithm classes, 746–749 synchronization locks, 391–395 SynchronizationContext class, 425–426 System.Configuration class, 534 System.Configuration namespace, 480–481 System.Drawing namespace classes, 320–323 overview, 319, 320 structures, 323–324 System.Globalization namespace, 919 System.Management namespace, 616–617 System.Net.Mail namespace, 889 System.Security.AccessControl namespace, 736–737 System.Security.Permission classes, 699 System.Security.Policy classes, 699 T technical support, xxxv terms application domains, 472–473 application security, 696–697 collections, 262 1036 tests, practice terms, continued configuring applications, 548 creating applications, 548 data security, 777–778 e-mail, 915 fundamentals, 63 globalization, 942 graphics, 362 input/output (I/O), 139–140 instrumentation, 624–625 interoperation, 825–826 mail, 915 NET Framework fundamentals, 63 reflection, 886 serialization, 313–314 text processing, 180 threading, 431–432 user security, 777–778 Windows services, 472–473 tests, practice application domains, 476 application security, 700 collections, 265–266 compared to lesson reviews, xxxiii configuring applications, 550 data security, 782 e-mail, 917–918 globalization, 944 graphics, 366 input/output (I/O), 142 installing, xxxiii installing applications, 550 instrumentation, 626 interoperation, 828 mail, 917–918 options, xxxiv overview, xxxii reflection, 888 serialization, 317 text processing, 183 threading, 434 types, 65–66 uninstalling, xxxiv user security, 782 using, xxxiii Windows services, 476 text formatting adding text to graphics, 349 controlling, 351–354 creating Font objects, 350 lab for adding copyright notices to pictures, 354–356 lab for adding legends to pie charts, 356–359 lab overview, 354 overview, 349 review, 360–361 summary, 360 writing text, 350–351 text processing encoding and decoding See encoding and decoding text forming regular expressions See forming regular expressions key terms, 180 overview, 143 practice tests, 183 prerequisites, 144 review, 180 scenario for processing data from legacy computers, 182 scenario for validating input, 181 suggested practices, 182–183 summary, 180 TextWriterTraceListener class, 585–586 Thread class, 369–371 threading Asynchronous Programming Model See Asynchronous Programming Model (APM) creating threads See creating threads key terms, 431–432 overview, 367–368 practice tests, 434 prerequisites, 368 review, 431 scenario for improving server processing, 432 scenario for multiple applications, 432–433 sharing data See sharing data between threads suggested practices, 433–434 summary, 431 ThreadPool class, 420–422 ThreadPriority enumeration, 376–377 ThreadState enumeration, 371–372 throwing exceptions, 23–25 Timer objects, 426–427 Trace class, 582–583 TraceSource class, 583 TraceSwitch class, 583 tracing See also debugging DefaultTraceListener class, 584–585 DelimitedListTraceListener class, 588 EventLogTraceListener class, 588 lab for creating application event logs, 589–590 listener objects overview, 584 overview, 581 review, 591–592 summary, 591 TextWriterTraceListener class, 585–586 Trace class, 582–583 TraceSource class, 583 TraceSwitch class, 583 XmlWriterTraceListener class, 586–588 using constraints type conversions boxing, 56 C# vs Visual Basic, 54–55 implementing in custom types, 56–59 lab for enabling option strict (Visual Basic), 60 lab for examining implicit conversions, 59–60 lab overview, 59 lesson review, 61 lesson summary, 60 overview, 54 summary, 63 unboxing, 56 Visual Basic vs C#, 54–55 type forwarding, 48–49 TypeBuilder class, 878–882 types conversions See type conversions practice tests, 65–66 reference See reference types scenario for designing applications, 64 serialization See serialization suggested practices See suggested practices value See value types U unboxing, 56 Unicode, 172–173 uninstalling practice tests, xxxiv unmanaged code calling Platform Invoke (P/Invoke), 807–809 converting data types, 810–811 encapsulating DLL functions, 809 exception handling in managed code, 819–821 lab for calling Windows DLL functions, 822–823 Layout.Explicit option, 816 Layout.Sequential option, 815 limitations, 822 marshaling structures, 811–815 overview, 807 review, 823–824 StructLayoutAttribute attribute, 812–815 summary, 823 using callback functions, 817–819 user-defined types, 7–10 user security See also data security access control lists See access control lists (ACLs) authentication and authorization overview, 704–706 authentication exceptions in streams, 724–725 creating custom identity classes, 716–720 creating custom principal classes, 720–721 creating custom user privilege models, 722–723 custom users and roles overview, 715 declarative RBS demands, 711–713 IIdentity interface, 716–720 1037 imperative RBS demands, 713–714 IPrincipal interface, 720–721 key terms, 777–778 lab for adding role-based security to applications, 725–729 overview, 701–702 practice tests, 782 prerequisites, 703 PrincipalPermission class, 710–711 RBS demands with custom identities and principals, 723–724 review, 730–731, 777 scenario for creating custom authentication methods, 778–780 suggested practices for accessing and modifying identity information, 781 suggested practices for implementing access control, 781–782 suggested practices for implementing custom authentication schemes, 781 summary, 729–730, 777 WindowsIdentity class, 706–707 WindowsPrincipal class, 708–710 using access control lists (ACLs) access control entries (ACEs), 734–736 analyzing ACLs, 737–738 calculating effective permissions with Windows, 733–734 configuring ACLs, 738–739 creating folders with explicit permissions, 739–740 DACL overview, 732 explicit permissions, 732 inherited permissions, 733 overview, 732 review, 741–742 security access control list (SACL), 735–736 summary, 740–741 System.Security.AccessControl namespace, 736–737 viewing from within assemblies, 736 using COM objects code, 791–792 handling exceptions in COM Interop, 792–794 importing type libraries, 786–787 importing types using TlbImp.exe, 788–790 importing types using Visual Studio 2005, 787–788 lab for using COM applications from NET, 794–795 limitations of COM Interop, 794 overview, 786 review, 796–797 Runtime Callable Wrapper (RCW), 786 summary, 796 tools used by COM Interop, 790–791 using companion CD, xxxii–xxxiii using constraints, 42–43 1038 using culture information using culture information CompareInfo class, 929–930 CompareOptions enumeration, 930–932 CultureInfo class, 920–924 CultureTypes enumeration, 925 DateTimeFormatInfo class, 927–929 invariant cultures, 921 lab for writing code that adjusts to culture, 932–934 neutral cultures, 921 NumberFormatInfo class, 927–929 overview, 920 RegionInfo class, 926–927 review, 935 specific cultures, 921 suggested practices, 943 summary, 934 using evaluation software DVD, xxxii–xxxiii using NET Framework 2.0 Configuration tool browsing configurations, 521–523 lab for changing and restoring application settings, 529 overview, 521 resetting configurations, 528–529 review, 531 summary, 530 using practice tests, xxxiii using reference types built-in reference types, 19 compared to value types, 17–18 creating arrays, 21 garbage collection, 17 lab for identifying types as value or reference, 26–27 lab for working with strings and arrays, 27–28 lab for working with strings and exceptions, 28–30 lab overview, 25 overview, 17 review, 30–31 strings and string builders, 19–21 summary, 30, 62 throwing exceptions, 23–25 using streams, 22–23 using specialized collections binary math, 230 BitArray class, 226–227 bits overview, 226 BitVector32 for bit masks, 228–229 BitVector32 for bit packing, 230–232 case-insensitive collections, 234 collecting strings overview, 232 culture-invariant collections, 235 lab for creating ListCollection for lookup tables, 238–239 NameValueCollection class, 235–237 review, 239–240 StringCollection class, 232–233 StringDictionary class, 233–234 summary, 239 using streams, 22–23 using unmanaged code calling Platform Invoke (P/Invoke), 807–809 converting data types, 810–811 encapsulating DLL functions, 809 exception handling in managed code, 819–821 lab for calling Windows DLL functions, 822–823 Layout.Explicit option, 816 Layout.Sequential option, 815 limitations, 822 marshaling structures, 811–815 overview, 807 review, 823–824 StructLayoutAttribute attribute, 812–815 summary, 823 using callback functions, 817–819 using value types built-in value types, 3–5 C# vs Visual Basic keywords, compared to reference types, 17–18 creating enumerations, 10–11 creating user-defined types, 7–10 declaring value types, 6–7 lab for adding enumeration to structures, 13–14 lab for creating structures, 11–13 lab for identifying types as value or reference, 26–27 lab overview, 11 lesson review, 15–16 lesson summary, 14 overview, summary, 62 Visual Basic vs C# keywords, V value types built-in, 3–5 C# vs Visual Basic keywords, compared to reference types, 17–18 creating enumerations, 10–11 creating user-defined types, 7–10 declaring, 6–7 lab for adding enumeration to structures, 13–14 lab for creating structures, 11–13 lab for identifying types as value or reference, 26–27 lab overview, 11 lesson review, 15–16 lesson summary, 14 overview, summary, 62 Visual Basic vs C# keywords, Visual Basic vs C# keywords, visualizers, 581 XmlWriterTraceListener class W wait-until-done model, 414–415 WaitHandle class, 403, 424–425 WebConfigurationManager class, 495–496 Windows services building setup projects, 462–463 compared to other projects, 458–459 controlling, 463–465 creating in Visual Studio, 457 creating install projects, 461–462 creating projects, 459–460 implementing, 460 installing manually, 462 key terms, 472–473 lab for creating service installers, 468–469 lab for creating services to monitor Web sites, 465– 468 lab for installing and managing, 469 lab overview, 465 managing, 463–465 monitoring files, 474–475 overview, 435, 457 practice tests, 476 prerequisites, 436 review, 470–472 suggested practices, 476 summary, 469–470, 472 WindowsIdentity class, 706–707 WindowsPrincipal class, 708–710 working with bits binary math, 230 BitArray class, 226–227 BitVector32 for bit masks, 228–229 BitVector32 for bit packing, 230–232 overview, 226 working with dictionaries Dictionary classes, 209–213 equality, 213–215 HybridDictionary class, 221 IEqualityComparer interface, 215–217 lab for creating lookup tables, 223–224 ListDictionary class, 220 OrderedDictionary class, 222–223 overview, 209 review, 225 SortedList class, 218–220 specialized dictionaries, 220 summary, 225 working with images Bitmap class, 342–343 creating and saving pictures, 343–345 displaying pictures, 343 icons, 345 Image class, 342–343 lab for saving pie charts as pictures, 345–346 overview, 342 review, 347–348 summary, 346 working with isolated storage creating stores, 127–128 IsolatedStorageFile class, 126–127 IsolatedStorageFilePermission class, 134 IsolatedStorageFileStream class, 129–130 lab for creating files, 135–136 lab for reading files, 136–137 lab overview, 135 overview, 125 permissions, 134–135 reading and writing data, 131–132 review, 137–138 summary, 137 using directories, 133–134 Write method, 571 WriteIf method, 571–572 WriteLine method, 572 WriteLineIf method, 572 writing dynamic code Binder class, 871–872 creating objects, 869–870 invoking members, 870 invoking static members, 871 lab for invoking members through reflection, 872–874 overview, 868 review, 874–875 summary, 874 writing files See reading and writing files writing output for debugging Assert method, 568–571 Debug class, 567–568 Debugger class, 564–567 Flush method, 573 overview, 564 Print method, 572–573 Write method, 571 WriteIf method, 571–572 WriteLine method, 572 WriteLineIf method, 572 X XML serialization See also object serialization conforming to XML schema, 295–296 controlling, 291–295 creating classes, 291 custom serialization See custom serialization deserializing objects, 290 lab for replacing binary serialization, 297–299 lab overview, 297 overview, 288–289 review, 300–301 serializing DataSet object, 296–297 steps for using, 289–290 summary, 300 XmlWriterTraceListener class, 586–588 1039 System Requirements We recommend that you use a computer that is not your primary workstation to the practice exercises in this book because you will make changes to the operating system and application configuration Hardware Requirements The following hardware is required to complete the practice exercises: ■ Computer with a 600-MHz or faster processor (1-GHz recommended) ■ 192 MB of RAM or more (512 MB recommended) ■ GB of available hard disk space ■ DVD-ROM drive ■ 1,024 x 768 or higher resolution display with 256 colors ■ Keyboard and Microsoft mouse, or compatible pointing device Software Requirements The following software is required to complete the practice exercises: ■ One of the following operating systems: ❑ Windows 2000 with Service Pack ❑ Windows XP with Service Pack ❑ Windows XP Professional x64 Edition (WOW) ❑ Windows Server 2003 with Service Pack ❑ Windows Server 2003, x64 Editions (WOW) ❑ Windows Server 2003 R2 ❑ Windows Server 2003 R2, x64 Editions (WOW) ❑ Microsoft Windows Vista ■ Visual Studio 2005 (A 90-day evaluation edition of Visual Studio 2005 Professional Edition is included on DVD with this book.) IMPORTANT Evaluation edition is not the full retail product The 90-day evaluation edition of Microsoft Visual Studio 2005 Professional Edition provided with this training kit is not the full retail product and is provided only for the purposes of training and evaluation Microsoft and Microsoft Technical Support not support this evaluation edition Information about any issues relating to the use of this evaluation edition with this training kit is posted to the Support section of the Microsoft Press Web site (www.microsoft.com/learning/support/ books/) For information about ordering the full version of any Microsoft software, please call Microsoft Sales at (800) 426-9400 or visit www.microsoft.com ... the (70-536) Microsoft NET Framework 2.0? ? ?Application Development Foundation lesson review to use the questions from the “Lesson Review” sections of this book Select the (70-536) Microsoft NET Framework. .. Web-based, Microsoft Windows-based, or distributed applications by using the NET Framework 1.0, the NET Framework 1.1, and the NET Framework 2.0 Candidates should have a working knowledge of Microsoft. .. them to Microsoft Press by using either of the following methods: E-mail: tkinput @microsoft. com Postal Mail: Microsoft Press Attn: MCTS Self-Paced Training Kit (Exam 70-536) : Microsoft NET Framework

Ngày đăng: 06/08/2013, 17:28

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN