Synopses & Reviews
Get the real-world coding guidelines, expert tips, and rock-solid guidance you need to take your development expertise to the next level. Drawing on their extensive programming and consulting experience, respected developers Francesco Balena and Giuseppe Dimauro share more than 700 programming best practices for Visual Basic and Visual C#. For each rule the authors explain the purpose, illuminate their whys and why-nots, highlight exceptions and alternatives, and provide real-world code samples.
Use the practical, reliable techniques in this book to:
- Take full advantage of the Microsoft .NET Framework—and write reusable, robust, and security-enhanced code
- Build software solutions that are both efficient and scalable
- Implement rational and easy-to-use class libraries and object hierarchies
- Adopt coherent coding styles and techniques to increase team productivity
- Extend your programming expertise, problem-solving skills, and creativity!
Find best practices for working with:
- assemblies
- resources and localization
- types and structures
- fields
- properties
- methods *constructors
- events
- interfaces
- exception handling
- custom attributes
- numbers and dates
- strings
- array and collection types
- memory usage and object finalization
- Windows Forms applications
- Microsoft ADO.NET
- Microsoft ASP.NET Web Forms and Web services applications
- threading and synchronization
- PInvoke and COM Interop
- serviced components
- remoting
- security considerations
- and more
Get code samples for Visual Basic and C# on the Web: For information on code samples and system requirements, please see Appendix C.
Synopsis
- Build reliable, scalable, and security-enhanced applications with expert advice from two renowned industry figures, Francesco Balena and Giuseppe Dimauro.
- Get hundreds of practical and timesaving tips in quick-reference format.
- Gain essential insights on the right and wrong approaches to various aspects of .NET-related programming.
- See best practices illustrated by code samples in Visual Basic and Visual C#, also available for download from a companion Web site.
Synopsis
Get the real-world coding guidelines, expert tips, and rock-solid guidance you need to take your development expertise to the next level. Drawing on their extensive programming and consulting experience, respected developers Francesco Balena and Giuseppe Dimauro share more than 700 programming best practices for Visual Basic and Visual C#. For each rule the authors explain the purpose, illuminate their whys and why-nots, highlight exceptions and alternatives, and provide real-world code samples.
Use the practical, reliable techniques in this book to: Take full advantage of the Microsoft .NET Framework--and write reusable, robust, and security-enhanced codeBuild software solutions that are both efficient and scalableImplement rational and easy-to-use class libraries and object hierarchiesAdopt coherent coding styles and techniques to increase team productivityExtend your programming expertise, problem-solving skills, and creativity
Find best practices for working with: assembliesresources and localizationtypes and structuresfieldspropertiesmethods *constructorseventsinterfacesexception handlingcustom attributesnumbers and datesstringsarray and collection typesmemory usage and object finalizationWindows Forms applicationsMicrosoft ADO.NETMicrosoft ASP.NET Web Forms and Web services applicationsthreading and synchronizationPInvoke and COM Interopserviced componentsremotingsecurity considerationsand more
Get code samples for Visual Basic and C# on the Web: For information on code samples and system requirements, please see Appendix C.
About the Author
Francesco Balena is a well-known and highly regarded developer and author. He has written numerous Microsoft Press(R) books, including the widely acclaimed Programming Microsoft Visual Basic(R) titles, and edits a popular Web site on .NET programming. Francesco is a cofounder of Code Architects srl, an Italian software company that specializes in using Microsoft technologies to create enterprise-level solutions and programming tools. In addition, he is a regional director for MSDN Italy, and a frequent speaker at developer conferences.
Table of Contents
Foreword; Introduction; Mission (Almost) Impossible: Writing Quality Software; Guideline Priority; Who Should Read This Book; Where to Look for More Information; Acknowledgments; Coding Guidelines and Best Practices; Chapter 1: Projects and Solutions; 1.1 Solution name; 1.2 Location of files in single-project solutions; 1.3 Location of files in multiple-project solutions; 1.4 Location of files in ASP.NET projects; 1.5 Project folders; 1.6 Source file name; 1.7 Executable EXE files; 1.8 Executable DLL files; 1.9 Source files shared among multiple projects; 1.10 Configuration files; 1.11 Compiler warnings [Visual Basic]; 1.12 Compiler warnings [C#]; 1.13 Compiler optimizations; 1.14 Debugging information; 1.15 Base address for DLLs; 1.16 Option Strict setting for new projects [Visual Basic]; 1.17 Option Strict setting for the current project [Visual Basic]; 1.18 The Option Strict directive [Visual Basic]; 1.19 Project-level custom constants; 1.20 VERSIONxyy custom compilation constant; 1.21 VERSION custom compilation constant [Visual Basic]; 1.22 Microsoft.VisualBasic project-wide imports [Visual Basic]; 1.23 Incremental builds [C#]; Chapter 2: Spaces and Indentation; 2.1 Indent by tabs; 2.2 Indentation width; 2.3 Consecutive blank lines; 2.4 Line length; 2.5 Line wrapping; 2.6 Curly braces [C#]; 2.7 Spaces and operators [C#]; 2.8 Spaces and parentheses [C#]; Chapter 3: Comments; 3.1 Spell checking and comments; 3.2 Language used for comments; 3.3 Consistent comment style; 3.4 Comment position and indentation; 3.5 XML comments [C#]; 3.6 XML comments in separate files [C#]; 3.7 Producing technical documentation; 3.8 The VBCommenter add-in [Visual Basic]; 3.9 Class- and method-level comments; 3.10 Block comments [C#]; 3.11 File header comments; 3.12 Block-level comments; 3.13 Statement-level comments; 3.14 Comments at the end of long blocks; 3.15 Comments for overloaded methods; 3.16 Comments for autogenerated code; 3.17 Remarks for commenting out code [C#]; 3.18 TODO and HACK comment tokens; 3.19 Custom policy comment tokens; Chapter 4: Assemblies and Resources; 4.1 The AssemblyInfo file; 4.2 Strong names; 4.3 Assembly size; 4.4 Multimodule assemblies; 4.5 CLS-compliant assemblies; 4.6 Assembly versioning; 4.7 Manifest resources vs. stand-alone files; 4.8 Resources vs. hard-coded string; 4.9 Resource names; 4.10 Satellite assemblies with localized resources; 4.11 Culture for main assembly; 4.12 Configuration settings; 4.13 GAC registration; 4.14 The Ngen utility; Chapter 5: Namespaces; 5.1 Primary namespace name; 5.2 Second-level namespace; 5.3 Logical organization of types inside namespace; 5.4 Number of types in each namespace; 5.5 Reduce namespace block nesting; 5.6 Types belong to namespaces; 5.7 One namespace for each source file; 5.8 .NET Framework namespace naming conventions; 5.9 Type dependency in nested namespaces; 5.10 Nested namespaces for special types; 5.11 Namespace-qualified member types; 5.12 Namespace aliasing; Chapter 6: Types; 6.1 Type names; 6.2 U.S. English for identifiers; 6.3 Abbreviations and acronyms; 6.4 Words to avoid; 6.5 One type per source file; 6.6 Type complexity; 6.7 Dependency on external variables; 6.8 Module names [Visual Basic]; 6.9 App type or module; 6.10 Globals class; 6.11 Member names from common interfaces; 6.12 Case sensitivity in member names [C#]; 6.13 Member ordering and grouping; 6.14 Language-specific member types; 6.15 Nested types; 6.16 Member scope; 6.17 Explicit scope qualifier; 6.18 Shadowed members; 6.19 Non-CLS-compliant types [C#]; 6.20 The Me/this keyword; 6.21 "New" member [C#]; 6.22 The Conditional attribute; 6.23 The Serializable attribute; 6.24 The Obsolete attribute; Chapter 7: Inheritance; 7.1 Object hierarchies; 7.2 Abstract classes; 7.3 Derived class names; 7.4 Base classes vs. interfaces; 7.5 Mandatory features in base classes; 7.6 Optional features in base classes; 7.7 Sealed classes; 7.8 Static classes; 7.9 Constructors in abstract types; 7.10 Protected members in sealed classes [Visual Basic]; 7.11 Virtual members; 7.12 Split long tasks in overridable methods; 7.13 Overloaded virtual methods; 7.14 ToString method overriding; 7.15 Equals method overriding; 7.16 GetHashCode method overriding; 7.17 GetHashCode method immutability; 7.18 GetHashCode method and equality; 7.19 MyClass keyword [Visual Basic]; 7.20 Equals and Compare strong-typed static methods; 7.21 Inheriting from MarshalByRefObject; Chapter 8: Interfaces; 8.1 Interface names;;;;;; 8.2 Interface types in one source file; 8.3 Number of members in interface types; 8.4 Events in interface types; 8.5 Interface immutability; 8.6 Name of classes implementing an interface; 8.7 Interface implementation in #region blocks; 8.8 Public vs. private members in interface implementation; 8.9 Private interface implementation in inheritable types; 8.10 ICloneable interface; 8.11 Strong-typed cloning; 8.12 Shallow and deep cloning; 8.13 Cloning immutable objects; 8.14 IComparable interface; 8.15 Leverage IComparable fields and properties; 8.16 IComparer interface; 8.17 IEnumerable and IEnumerator types; 8.18 Strong-typed members in interface implementation; 8.19 ISerializable interface; Chapter 9: Structures; 9.1 Value types vs. reference types; 9.2 Structures instead of classes with value type members; 9.3 Structure size; 9.4 Default state of structure members; 9.5 Equals overload in value types; 9.6 Interface implementation in structures; 9.7 IDisposable structures [C#]; Chapter 10: Enum Types; 10.1 Enum types in one source file; 10.2 Enum types nested in another type; 10.3 Enum type names; 10.4 Flags attribute for bit-coded enum types; 10.5 Base type for enum types; 10.6 Member names in enum types; 10.7 Values in non-bit-coded enum types; 10.8 Values in bit-coded enum types; 10.9 Default value for enum types; 10.10 Default value for bit-coded enum types; 10.11 Reserved enum values; 10.12 Validation of enum values; 10.13 Validation of bit-coded enum values; Chapter 11: Attribute Types and Reflection; 11.1 Applying attributes; 11.2 Applying multiple attributes to the same member [C#]; 11.3 Custom attribute type names; 11.4 Sealed custom attribute types; 11.5 Constructors in custom attribute types; 11.6 Overloaded constructors in custom attribute types; 11.7 The AttributeUsage attribute; 11.8 Attribute vs. marker interfaces; 11.9 Checking for a custom attribute; 11.10 Loading an assembly for reflection purposes; 11.11 Using the StackTrace object; 11.12 Invoking a method through reflection; Chapter 12: Fields and Variables; 12.1 Field and variable names; 12.2 Constant names; 12.3 Hungarian notation; 12.4 Common prefixes for variable names; 12.5 Explicit private scope for fields; 12.6 Multiple declarations on same line; 12.7 Constant values; 12.8 Read-only fields; 12.9 Public instance fields; 12.10 Public static fields; 12.11 Protected fields; 12.12 Local variables; 12.13 Static local variables [Visual Basic]; 12.14 Block variables; 12.15 Block variable initialization [Visual Basic]; 12.16 Name of fields wrapped by properties; 12.17 Location of fields wrapped by properties; 12.18 References to fields wrapped by properties; 12.19 Field initialization; 12.20 Simplified syntax for object instantiation [Visual Basic]; 12.21 The DirectCast operator [Visual Basic]; 12.22 The assignment operator inside expressions [C#]; 12.23 The as operator [C#]; 12.24 The With keyword [Visual Basic]; 12.25 Temporary variables for nested objects [C#]; 12.26 Nonserializable fields; 12.27 IntPtr fields and properties; Chapter 13: Properties; 13.1 Property names; 13.2 Property size; 13.3 Compact formatting for properties [C#]; 13.4 Validation and assignment in properties; 13.5 Properties vs. methods; 13.6 Read-only properties; 13.7 Write-only properties; 13.8 Properties with arguments; 13.9 Default properties [Visual Basic]; 13.10 The value keyword [C#]; 13.11 Alternate friendly names for indexers [C#]; 13.12 Is-prefixed Boolean read-only properties; 13.13 Properties that return arrays; 13.14 Properties that return collections; Chapter 14: Methods; 14.1 Method names; 14.2 Method size; 14.3 Number of arguments; 14.4 Parameter names; 14.5 Reserved parameters; 14.6 Parameters typed as base classes; 14.7 Argument validation; 14.8 The ByVal keyword [Visual Basic]; 14.9 Reference types passed by reference; 14.10 ref and out arguments [C#]; 14.11 Multiple by-reference arguments; 14.12 Optional parameters [Visual Basic]; 14.13 Variable number of parameters; 14.14 Multiple parameters of same type; 14.15 Special-case methods with a variable number of parameters; 14.16 Single exit point; 14.17 The Return keyword [Visual Basic]; 14.18 Returning the result of an expression; 14.19 Method overloading to reduce boxing; 14.20 Method overloading to reduce number of arguments; 14.21 Method overloading based on argument-passing style [C#]; 14.22 Overloaded method chaining; 14.23 Number of local variables; 14.24 Get-prefixed methods; 14.25 Get-prefixed methods matching property names; 14.26 Set-prefixed methods; 14.27 Method names that include type of returned value; 14.28 Factory method names; 14.29 Factory method parameters; 14.30 Operator overloading in reference types [C#]; 14.31 == and != operator overloading [C#]; 14.32 Modifying arguments in overloaded operators [C#]; 14.33 Alternative methods for operator overloading [C#]; 14.34 Conversion and parsing methods; 14.35 URI values; Chapter 15: Constructors; 15.1 Parameter names; 15.2 Constructor size; 15.3 Assignments to writable properties; 15.4 Assignments to read-only properties; 15.5 Explicit parameterless constructor; 15.6 Main constructor for robust instances; 15.7 Additional constructors for ease of use; 15.8 Private constructors; 15.9 Friend and internal constructors; 15.10 Protected Friend and protected internal constructors; 15.11 Static constructors in reference types; 15.12 Static constructors in value types; 15.13 Delegating to constructors with more parameters; 15.14 Delegating to constructors with fewer parameters; 15.15 Private parameterless constructor to help delegation; 15.16 Constructors that take a disposable object; 15.17 Calling virtual methods from inside a constructor; 15.18 Exceptions in constructors; 15.19 Exceptions in static constructors; Chapter 16: Dispose and Finalize Methods; 16.1 The IDisposable interface; 16.2 Dispose and Finalize methods; 16.3 Implementing only the Finalize method; 16.4 using blocks for disposable objects [C#]; 16.5 Invoking Dispose in the Finally block [Visual Basic]; 16.6 Dispose vs. Close method; 16.7 Field access in Finalize method; 16.8 Error handling in the Finalize method [Visual Basic]; 16.9 Throwing DisposedObjectException; 16.10 The Dispose-Finalize pattern; 16.11 The Dispose-Finalize pattern in derived types; Chapter 17: Delegates and Events; 17.1 Delegate and event names; 17.2 EventArgs-derived type names; 17.3 Delegate naming style; 17.4 Event naming style; 17.5 Name of event-handling methods; 17.6 Scope of event-handling methods; 17.7 Delegate invocation; 17.8 Delegates vs. interfaces for callback methods; 17.9 Instantiation of delegate objects [Visual Basic]; 17.10 Event syntax; 17.11 Event definition through delegates [Visual Basic]; 17.12 Event return type; 17.13 Event raising [C#]; 17.14 Event unsubscription; 17.15 Events that notify a property change; 17.16 Raising events from inside overridable methods; 17.17 The hidden event variable [Visual Basic]; 17.18 WithEvents variables [Visual Basic]; 17.19 Reentrancy issues when raising events; 17.20 Raising events from secondary threads; 17.21 Implementing the SynchronizingObject property; 17.22 Events in Finalize methods; 17.23 Events in serializable classes; Chapter 18: Execution Flow; 18.1 Multiple statements on one line; 18.2 Empty parentheses in method calls [Visual Basic]; 18.3 Invoking static methods [Visual Basic]; 18.4 Invoking methods in modules [Visual Basic]; 18.5 Single-statement If blocks [Visual Basic]; 18.6 Single-statement conditional and loop blocks [C#]; 18.7 Nested conditional and loop blocks; 18.8 AndAlso and OrElse operators [Visual Basic]; 18.9 Comparisons with true/false; 18.10 Conditional blocks to assign a Boolean value; 18.11 The ternary operator (? :) [C#]; 18.12 The IIf function [Visual Basic]; 18.13 Testing and comparing object types; 18.14 Testing a variable for multiple values [Visual Basic]; 18.15 Statements in Case blocks [Visual Basic]; 18.16 Order of Case blocks; 18.17 Asserting the default case; 18.18 GoTo keyword [Visual Basic]; 18.19 goto keyword [C#]; 18.20 Variable declaration in For and For Each loops [Visual Basic]; 18.21 Array upper limit in For loops; 18.22 Modifying the controlling variable in For loops; 18.23 Floating-point variables in For loops; 18.24 Constant subexpressions in loops; 18.25 While loops [Visual Basic]; 18.26 Unsafe code [C#]; Chapter 19: Exception Handling; 19.1 Exception variable names; 19.2 Custom exception type names; 19.3 The On Error statement [Visual Basic]; 19.4 Using exceptions to control execution flow; 19.5 Throwing specific exception objects; 19.6 Throwing on Dispose and Close methods; 19.7 Exception message style; 19.8 Localized error messages; 19.9 XML remarks documenting which exceptions a method can throw [C#]; 19.10 Remarks documenting which exceptions a method can throw [Visual Basic]; 19.11 Can-prefixed read-only properties to prevent exceptions; 19.12 Order of Catch blocks [Visual Basic]; 19.13 The When keyword [Visual Basic]; 19.14 Setting return values in Finally blocks [Visual Basic]; 19.15 Undoing state in Catch blocks; 19.16 Catching SystemException and ApplicationException; 19.17 Catching DivideByZeroException; 19.18 Catching special .NET exceptions; 19.19 Throwing NotSupportedException vs. NotImplementedException; 19.20 Catching exceptions in class libraries; 19.21 Rethrowing original exceptions; 19.22 Rethrowing exceptions of a different type; 19.23 Exception logging; 19.24 Defining custom exception types; 19.25 Overall structure of custom exception types; 19.26 Constructors in custom exception types; 19.27 Exceptions in constructors of custom exception types; 19.28 Serialization in custom exception types; 19.29 Base class for custom exception types; Chapter 20: Numeric Types; 20.1 Constants in lieu of "magic" numbers; 20.2 Integer field width; 20.3 Unsigned integers [C#]; 20.4 The checked and unchecked keywords [C#]; 20.5 Language-specific math functions [Visual Basic]; 20.6 Shortened notation for common math operations; 20.7 ++ and -- operators [C#]; 20.8 Multiple ++ and -- operators in same expression [C#]; 20.9 Conversion of Boolean values to integers; 20.10 Shift operators [Visual Basic]; 20.11 Division operators [Visual Basic]; 20.12 Decimal variables; 20.13 Floating-point variables; 20.14 Equality test for floating-point values; 20.15 Floating-point temporary results [Visual Basic]; 20.16 Multiplication instead of division; 20.17 Multiplication instead of exponentiation; Chapter 21: Strings; 21.1 Strings used in the user interface; 21.2 The & Operator [Visual Basic]; 21.3 Char variables; 21.4 String variable initialization; 21.5 Long string expressions; 21.6 Methods and properties that return strings; 21.7 Language-specific string functions [Visual Basic]; 21.8 Verbatim (@) string constants [C#]; 21.9 Strings containing control characters [Visual Basic]; 21.10 ChrW vs. Chr function [Visual Basic]; 21.11 Looping over all the characters of a string [Visual Basic]; 21.12 Checking for null strings; 21.13 Checking for empty strings; 21.14 Case-insensitive comparisons; 21.15 Three-case string comparisons; 21.16 String comparisons with CompareOrdinal; 21.17 Searching and replacing with regular expressions; 21.18 Validating with regular expressions; 21.19 Concatenating a fixed number of strings; 21.20 Concatenating a variable number of strings; 21.21 StringBuilder initialization; 21.22 StringBuilder reuse; 21.23 Configuration-dependent strings; 21.24 Setting the culture for the current thread; 21.25 Culture-aware parsing and formatting; Chapter 22: Arrays and Collections; 22.1 Array and collection object names; 22.2 Custom collection type names; 22.3 Nonzero bound arrays; 22.4 Arrays and collections in performance-critical code; 22.5 Array initialization; 22.6 Jagged arrays; 22.7 The Collection object [Visual Basic]; 22.8 Methods and properties that return arrays and collections; 22.9 Loops over array and collection elements; 22.10 Looping over two-dimensional matrices; 22.11 Large arrays of Boolean values; 22.12 Generic vs. strong-typed collections; 22.13 Collection initial capability; 22.14 Collection growth factor; 22.15 Adding multiple elements to a collection; 22.16 The SortedList object; 22.17 Case-insensitive Hashtable and SortedList collections; 22.18 Iterating over Hashtable or SortedList collections; 22.19 Custom collection classes; 22.20 Custom dictionary classes; 22.21 Zero-based indexers; Chapter 23: Memory Usage; 23.1 Early creation of long-lasting objects; 23.2 Boxing; 23.3 Clearing object references; 23.4 Clear object references explicitly in loops; 23.5 Keeping objects alive; 23.6 Explicit garbage collections in server applications; 23.7 Explicit garbage collections in client applications; 23.8 Waiting for finalizers after explicit garbage collections; 23.9 Large object heap fragmentation; 23.10 Compound finalizable objects; 23.11 WeakReference objects; 23.12 Garbage collector settings; .NET Framework Guidelines and Best Practices; Chapter 24: Files, Streams, and XML; 24.1 Custom stream names; 24.2 Working with file and directory names; 24.3 Absolute file paths; 24.4 User data files; 24.5 Temporary files; 24.6 Reading files; 24.7 Closing StreamWriter and BinaryWriter objects; 24.8 Creating file associations; 24.9 Adding data files to the recent document list; 24.10 Using isolated storage; 24.11 Writing XML text; 24.12 Reading and writing XML files; 24.13 Searching XML nodes; 24.14 DateTime serialization; Chapter 25: PInvoke and COM Interop; 25.1 The DllImport attribute [Visual Basic]; 25.2 All external methods in one type; 25.3 IntPtr parameters; 25.4 The SetLastError option; 25.5 Explicitly release COM objects; 25.6 Signed interop assemblies; 25.7 Using Primary Interop Assemblies; 25.8 Building Primary Interop Assemblies; 25.9 Setting properties vs. invoking methods; 25.10 Blittable arguments and return values; 25.11 Variant arguments; 25.12 Delegate arguments; 25.13 COM-friendly .NET components; 25.14 The ComVisible attribute; 25.15 The DispId attribute; 25.16 The ComClass attribute [Visual Basic]; 25.17 The ClassInterface attribute; 25.18 Exposing .NET events to COM clients; 25.19 The ComRegisterFunction and ComUnregisterFunction attributes; Chapter 26: Threading; 26.1 Thread name; 26.2 The IsBackground property; 26.3 The Suspend, Resume, and Abort methods; 26.4 The AppDomain.GetCurrentThreadId method; 26.5 The Sleep method; 26.6 The Join method; 26.7 The ThreadAbortException type; 26.8 SyncLock and lock blocks; 26.9 Synchronized methods; 26.10 Nested synchronization blocks; 26.11 Objects in synchronization blocks; 26.12 System.Type objects in synchronization blocks; 26.13 Synchronizing on arrays and collections; 26.14 Synchronized collections; 26.15 Synchronizing access to Windows Forms objects; 26.16 volatile fields [C#]; 26.17 Thread-safe singleton objects; 26.18 Synchronizing on multiple objects; 26.19 ReaderWriterLock objects; 26.20 Base class for threading; 26.21 Asynchronous delegates; 26.22 Expose asychronous methods in your classes; 26.23 Timers; Chapter 27: Windows Forms Applications; 27.1 Form names; 27.2 Loading startup form from Main method; 27.3 The STAThread attribute; 27.4 Windows Forms object and control names; 27.5 Menu item names and shortcuts; 27.6 GDI+ object names; 27.7 Windows component names; 27.8 ADO.NET Components; 27.9 Control scope; 27.10 Autogenerated code; 27.11 Business logic; 27.12 Resizable forms; 27.13 Scrolling and tabbed forms; 27.14 Read control properties from resource files; 27.15 Common logic in base forms; 27.16 Tool windows; 27.17 The DialogResult property; 27.18 The MsgBox command [Visual Basic]; 27.19 Support for Windows XP Themes; 27.20 Caption for MDI forms; 27.21 Menu and toolbar commands; 27.22 Help for individual controls; 27.23 TabIndex ordering; 27.24 Control accelerator keys; 27.25 The UseMnemonic property; 27.26 Control validation; 27.27 The CausesValidation property; 27.28 Appending text to a text box; 27.29 Multilined text boxes; 27.30 Global error handlers; 27.31 React to screen resolution changes; 27.32 Lengthy operations; 27.33 The DoEvents method; 27.34 The AccessibleName property; 27.35 Using the registry; 27.36 Previous application instances; 27.37 Browsable properties in controls and components; Chapter 28: ADO.NET Programming; 28.1 ADO.NET object names; 28.2 Error handling for database operations; 28.3 Native .NET data providers; 28.4 Provider-agnostic code; 28.5 Connection strings; 28.6 ADO.NET object constructors; 28.7 Authentication mode for SQL Server databases; 28.8 The PacketSize property; 28.9 Primary keys in database tables; 28.10 Asynchronous database operations; 28.11 DataReader vs. DataSet; 28.12 Filtering data; 28.13 Sorting, and grouping; 28.14 Reading individual rows; 28.15 Reading individual values; 28.16 Limit the number of rows in a resultset; 28.17 NULL values in queries; 28.18 Special characters in LIKE queries; 28.19 Close a connection automatically; 28.20 Cancel a DataReader query; 28.21 Parameterized commands vs. dynamic SQL queries; 28.22 Reusing SqlCommand objects; 28.23 Parameterized commands vs. stored procedures; 28.24 SQL Server stored procedure names; 28.25 Access tables through views and stored procedures; 28.26 Stored procedures that return a value; 28.27 Large binary and text fields; 28.28 Process large binary and text fields in chunks; 28.29 Resultset pagination; 28.30 Batch commands for SQL Server queries; 28.31 DataSet names; 28.32 DataTable names; 28.33 DataRelation names; 28.34 Strong-typed DataSet classes; 28.35 DataSet vs. DataTable objects; 28.36 The DataSet and DataTable Locale property; 28.37 The DataAdapters autoconnect feature; 28.38 CommandBuilder objects; 28.39 Autoincrementing identity columns; 28.40 DataSet serialization; 28.41 Reading master-detail tables; 28.42 Advanced SQL Generation Options dialog box; 28.43 TimeStamp fields for optimistic concurrency; 28.44 Transaction duration; 28.45 Resolving update conflicts; 28.46 Using the DataSet in transactional updates; 28.47 Updating master-detail tables; Chapter 29: ASP.NET Web Forms Applications; 29.1 Web Forms control names; 29.2 HTML control names; 29.3 Main page properties; 29.4 The pageLayout property; 29.5 The targetSchema property; 29.6 The SmartNavigation property; 29.7 The EnableViewState property; 29.8 The page title; 29.9 Accounting for Web crawlers; 29.10 Disabling debug mode in production sites; 29.11 Deprecated Response properties; 29.12 Using ViewState vs. manually restoring controls contents; 29.13 AutoPostBack controls; 29.14 Image-based and hyperlink-based controls; 29.15 User input validation; 29.16 Formatting and parsing according to user language; 29.17 Displaying data from files or database fields; 29.18 Asking for confirmation before critical operations; 29.19 Client-side and server-side data validation; 29.20 Checking mandatory fields; 29.21 Checking data type in input fields; 29.22 Syntax restrictions in the RegularExpressionValidator control; 29.23 Accepting uploaded files from the user; 29.24 Size and type constraints on uploaded files; 29.25 Checking filenames; 29.26 Opening and closing database connections; 29.27 SQL Server authentication in Web applications; 29.28 Lengthy server-side operations; 29.29 Data binding in Web Forms; 29.30 Displaying multiple database columns in databound list controls; 29.31 The ItemCommand event; 29.32 State management: The ViewState dictionary; 29.33 State management: The in-process Session dictionary; 29.34 State management: The service-based Session dictionary; 29.35 State management: The SQL Serverbased Session dictionary; 29.36 State management: Cookies; 29.37 State management: Hidden fields; 29.38 State management: The Application dictionary; 29.39 State management: Global static variables; 29.40 Disabled and read-only sessions; 29.41 ViewState and Session elements as properties; 29.42 ViewState, Session, Application, and Cache element names; 29.43 The EnableViewStateMac property; 29.44 The ViewStateUserKey property; 29.45 ViewState validation and encryption in Web gardens; 29.46 ViewState validation and encryption in Web farms; 29.47 Redirecting to another page; 29.48 Passing data between pages: The query string; 29.49 Passing data between pages: The Context.Items collection; 29.50 Passing data between pages: The Context.Handler property; 29.51 Passing local URLs to another application; 29.52 Using COM and COM+ legacy components; 29.53 Caching the pages contents; 29.54 The Cache object; 29.55 Global error handlers; 29.56 Custom errors; 29.57 Application-level tracing; 29.58 ASP.NET identity; 29.59 Encrypted credentials and connection strings in Web.config; 29.60 URL authorization; 29.61 Configuration settings for forms authentication; 29.62 Custom forms authentication; 29.63 Forms authentication cookies; 29.64 Robust password policy; 29.65 Client-side scripts; 29.66 Centralized configuration files; 29.67 Removing unused HTTP modules; Chapter 30: ASP.NET Web Services; 30.1 Name of .asmx files; 30.2 The WebService attribute; 30.3 The WebMethod attribute; 30.4 The SoapInclude attribute; 30.5 Caching method results; 30.6 Proxy class namespace; 30.7 Synchronous invocations; 30.8 Asynchronous invocations; 30.9 Support for proxy servers; 30.10 The CookieContainer property; 30.11 SOAP headers; 30.12 One-way Web service calls; 30.13 Web Service Enhancements (WSE); Chapter 31: Serviced Components; 31.1 COM+ transactions vs. ADO.NET transactions; 31.2 Static members; 31.3 Library vs. server components; 31.4 Assembly-level attributes; 31.5 The ClassInterface attribute; 31.6 The JustInTimeActivation attribute; 31.7 The AutoComplete attribute; 31.8 The Transaction attribute; 31.9 Isolation level for nonroot components; 31.10 Types with methods that require different isolation levels; 31.11 Poolable objects; 31.12 The ApplicationAccessControl attribute; 31.13 The authentication level; 31.14 The impersonation level; 31.15 The ComponentAccessControl attribute; 31.16 The SecurityRole attribute; 31.17 COM+ role-based security at the method level; 31.18 Programmatic security; 31.19 Component identity; 31.20 Disposing of a serviced component; 31.21 WebMethod attributes in serviced components; Chapter 32: Remoting; 32.1 Remotable types; 32.2 Host applications for .NET remoting; 32.3 Port numbers; 32.4 URI extensions; 32.5 Server-Activated vs. Client-Activated Objects; 32.6 Declarative vs. programmatic configuration; 32.7 Loading a .NET remoting configuration file; 32.8 TCP vs. HTTP channel; 32.9 The rejectRemoteRequests attribute; 32.10 The typeFilterLevel attribute; 32.11 The <customErrors> tag; 32.12 Hosting remoting objects in IIS; 32.13 Never-expiring Singleton objects; 32.14 One-way remoting calls; 32.15 The Soapsuds tool; 32.16 Using shared interfaces with SAOs; 32.17 Using shared interfaces and factory methods with CAOs; 32.18 Integrated Windows security in IIS; 32.19 Basic authentication security in IIS; 32.20 Exchanging data between different time zones; Chapter 33: Security; 33.1 Assembly-level permission requests; 33.2 Demand permissions at application startup; 33.3 Declarative vs. imperative security actions; 33.4 The AllowPartiallyTrustedCallers attribute; 33.5 Assert security actions; 33.6 Deny and PermitOnly security actions; 33.7 Security in event handlers and delegates; 33.8 Security in exception handlers; 33.9 LinkDemand security actions; 33.10 InheritanceDemand security actions; 33.11 The SuppressUnmanagedCodeSecurity attribute; 33.12 Mixing type-level and method-level imperative security; 33.13 Security checks in value types; 33.14 Types implementing the ISerializable interface; 33.15 The StrongNameIdentityPermission attribute; 33.16 Protect libraries from unauthorized use; 33.17 Policy level for ASP.NET applications; 33.18 Setting the principal policy; 33.19 Role-based security; 33.20 Applying ACLs for configuration and data files; 33.21 Encrypting data; 33.22 Hashing data files; 33.23 Protecting serialized objects; 33.24 Storing user passwords; 33.25 Random data for cryptographic purposes; 33.26 Random data from user passwords; 33.27 Obfuscating code; Test; The FxCop Tool; Source Code and Other Goodies; About the Authors; Francesco Balena; Giuseppe Dimauro;