Index

■Special Characters data adapter objects, 811–12 #elif, preprocessor directive, 317–18 data providers overview, 759–62 #else, preprocessor directive, 317–18 data wizards, 822–25 #endif, preprocessor directive, 317–18 DataColumn objects, 796, 798 #endregion, preprocessor directive, 317 DataRelation objects, 817–20 #if, preprocessor directive, 317–18 DataRow objects, 798–99, 801 #region, preprocessor directive, 317 DataRow.RowState property, 799–800 #undef, preprocessor directive, 317–19 DataSet class, 794–96 & operator, pointer types, 312–13 datasets in XML web services, 950 * operator, pointer types, 312–13 DataTable objects, 800 ?? operator, 133 DataTableReader objects, 802 += operator, 610 DataView objects, 810 <%@Page%> directive, ASP.NET, 846 DbDataReader object, 782–83 <%Import%> directive, ASP.NET, 846–47 definition, 759–60 ? suffix, nullable types, 131 deleting records, 787 deleting rows, 806–7 ■A disconnected layer, 793 A# programming language, 8 example database, 775 Abort( ) method, Thread type, 460 example, data provider factory, 772–74 abstract base classes contrasted with interfaces, filling DataSet, 812 224 filters, 807–8 abstract classes, 16, 164–65, 166 Firebird Interbase data provider, 763 abstract members (interface), 221 IBM DB2 Universal Database data providers, abstract methods, 166–69 763 AcceptChanges( ), RejectChanges( ) methods, IDbCommand interface, 766 ADO.NET, 795–98 IDbConnection interface, 765 AcceptsReturn property, Textbox, 705 IDbDataAdapter, IDataAdapter interface, 767 access modifiers, 76–78 IDbDataParameter, IDataParameter Add Reference dialog box, 356, 359–60 interface, 766 AddCacheDependency( ) method, ASP.NET IDbDataReader, IDataReader interface, HTTP Response, 860 767–68 adding controls, ASP.NET, 869–70 IDbTransaction interface, 765 AddRange( ) method, ControlCollection, 702 inserting records, 786 ADO.NET mapping DBMS names, 813 additional namespaces, 763–64 data providers, 762–63 vs. ADO classic, 759–60 modifying tables, Command object, 784–86 application configuration files, 769–70 multiple result sets, DbDataReader object, asynchronous data access, 792–93 784 autogenerated data components, 824–25 multitabled DataSet objects, 817–20 autogenerating SQL commands, 816–17 MySQL data providers, 763 autoincrementing, 797 navigating between related tables, 820–21 binding DataTables to user interfaces, 804, 806 overview, 759 Command object, 781–82 parameterized command objects, 788 connected layer, 778 persisting datasets as XML, 803 connected vs. disconnected layer, 760 PostgreSQL providers, 763 connecting to database, Visual Studio 2005, provider factory model, 770–72 776 sort order, 807–8 connection objects, 779–80 specifying DbParameter parameters, 788–90 ConnectionStringBuilder object, 780–81 stored procedures using DbCommand, connectionStrings element, application 790–91 configuration, 774–75 strongly typed datasets, 823–24 955 956 ■INDEX

System.Data, 764 notepad.exe development editor, 33 third-party data providers, 763 overview, 33 updating records, 787 SharpDevelop, 33 updating rows, 809 TextPad development editor, 41 updating using data adapter objects, 813–15 Visual C# 2005 Express, 33 using interfaces, 768–69 application domain, garbage collection, 188 view objects, 810 application level state data, ASP.NET, 898–99 AdRotator example, ASP.NET, 874 Application, Page Type properties, 856 AllKeys property, ASP.NET HttpApplicationState Application property, WebService base class, members, 898 929 AllowDBNull property, ADO.NET DataColumn application root categories, 182–83 object, 796 application shutdown, ASP.NET, 900 AnchorStyles enumeration values, 755 Application_End( ), Global.asax event handlers animation in controls, 743 in ASP.NET, 896 anonymous methods Application_Error( ), Global.asax event handlers description, 282 in ASP.NET, 896 example, 283–84 Application_Start( ), Global.asax event handlers App_Browsers, ASP.NET 2.0 subdirectories, 851 in ASP.NET, 896 App_Code, ASP.NET 2.0 subdirectories, 851, 853 ApplicationExit event, Application class, 609 App_Data, ASP.NET 2.0 subdirectories, 851 ApplicationId, RemotingConfiguration, 580 App_GlobalResources, ASP.NET 2.0 ApplicationName, RemotingConfiguration, 580 subdirectories, 851 applications vs. sessions, ASP.NET, 897 App_LocalResources, ASP.NET 2.0 appSetting element, Web.config, ASP.NET, 912 subdirectories, 851 array types, 127–28 App_Themes, ASP.NET 2.0 subdirectories, 851 ArrayList System.Collections class type, 250–51 App_WebReferences, ASP.NET 2.0 arrays subdirectories, 851 jagged, 129–30 AppDomains multidimensional, 128 advantages, 435 as parameters and return values, 128 creation example code, 437 using interface types in, 228 loading example code, 438 in XML web services, 949 manipulation example code, 436–37 as keyword overview, 425 determining interface support, 225 relationship to processes, 435 determining type, 172 thread relationship, 449 ASP.NET unloading example code, 439–40 <%@Page%> directive, 846 AppendText( ) method, FileInfo class, <%Import%> directive, 846–47 System.IO, 526, 528–29 adding and removing controls, 869–70 Application, ASP.NET HttpApplication AdRotator example, 874 members, 897 AutoEventWireUp attribute, 862–63 application cache, ASP.NET, 901 AutoPostBack property, 866 Application class browser statisics in HTTP Request ApplicationExit event, 609 processing, 858 CompanyName property, 609 categories of web controls, 871–72 DoEvents( ) method, 609 classic ASP, 838, 840 EnableVisualStyles( ) method, 609 client-side scripting, 836 ExecutablePath property, 609 client-side scripting example, 836–37 Exit( ) method, 609 code-behind, description, 842 Idle event, 609 code-behind page model, 847–49 ProductName property, 609 compilation cycle ProductVersion property, 609 multifile pages, 854–55 StartupPath property, 609 single-file pages, 853–54 ThreadExit event, 609 debugging and tracing, 849–50 Application class, System.Windows.Forms, 606 default.aspx content page example, 875–76 application configuration files, ADO.NET, detailed content page example, 881–83 769–70 Document Object Model (DOM), 836 application development Emitting HTML, 860 cordbg.exe debugger, 33, 40–41 enumerating controls with Panel control, csc.exe compiler, 33–36 867–68 .NET 2.0 Framework SDK, general guide, 33 Error event, 863–64 ■INDEX 957

form control declarations, 847 assemblies GET and POST, 837–38 Add Reference dialog box, 356, 359–60 HTML app.config file, 368 document structure, 833 binary code reuse, 347 form development, 833 CIL code, 351, 358 overview, 832 client application example, 359–60 web controls, 871 CLR file header, 350–51 HTTP code base config file element, 385, 387 overview, 829–30 code library, 347 Request members, 857 compared with legacy executables, 347 Request processing, 857–59 consuming shared assemblies, 376–77 Response members, 860 cross-language inheritance, 362 Response processing, 859–61 definition, 347 IIS virtual directories, 831 delayed digital signing, 375–76 incoming form data, 858–59 dependentAssembly config file element, 381–82 inheritance chain, page type, 855–56 download cache, 352 in-place editing example, 879–80 dynamic redirection to a specific version, Internet Information Server (IIS), 381–82 description, 830 embedded resources, 352 inventory content page example, 877–78 example of version updating, 379–82 IsPostBack property in HTTP Request explicit load request, 366, 368 processing, 859 flow of CLR external reference resolution, 388 life cycle of web page, 861–63, 865 global cache (GAC), 25, 348 master pages example, 872–73 ildasm exploration of manifest, 357 menu control example, 873 implicit load request, 366, 368 overview, 829 internal format, 349 page type inheritance chain, 855–56 language integration, 360, 362, 364–65 redirecting users, 861 manifest, 348, 351, 357 request/response cycle, HTTP, 829 manifest description, 11 round-trips (postbacks), 836 metadata description, 10 runat attribute, 847 module-level manifest, 364 script block, 847 modules, 11, 352 server-side event handling, 865 multifile, 352, 362–65 simple web controls, 871 .NET Framework Configuration utility, simple website example, 872–75, 877–83 369–70, 382 single file code model, 842–43 netmodule file extension, 352, 362–64 sorting and paging example, 878–79 overview, 10, 347 stateless, description, 830 private, 365–66, 368 submitting form data, 837–38 probing process, 366, 368 System.Web.UI.Control, 866–67, 869–70 publisher policy assemblies, 384–85 System.Web.UI.Page, 856 referencing external, 25 System.Web.UI.WebControls namespace, and resource files, 693 865–66 satellite assemblies, 352 System.Web.UI.WebControls.WebControl, self-describing, 348 870 shared assemblies, 371 user interface in HTML, 834–35 configuration, 378–79 using web controls, 865–66 and the GAC, 374 validating form data, 837 shared assembly manifest, 378 validation controls, 883, 885–88 single-file, 352 version 1.x benefits, 840 example, 354–56 version 2.0 benefits, 841 vs. multifile, 11 version 2.0 namespaces overview, 841 strong names, 348, 357, 371, 373–74 web application, description, 830 assigning using Visual Studio 2005, 374 web development server, 832 code example, 373 web page code model, 842–46 type metadata, 348, 351, 358 web server, description, 830 updating applications using shared WebControl base class properties, 870–71 assemblies, 378–79 website directory structure, 851 version number, 348 ASP.NET 2.0 namespaces, 842 Visual Studio 2005 configuration, 368 ASP.NET 2.0 subdirectories, 851–53 Win32 file header, 349 958 ■INDEX

Assembly class, System.Reflection, 396, 402–6 attributes, assembly, module level, 415 assembly directive, common intermediate Attributes property, FileSystemInfo class, 519, language (CIL), 488 521 assembly manifest, 15 AttributeUsage attribute, 414 assembly metadata, const values, 81 authentication element, Web.config, ASP.NET, AssemblyBuilder, System.Reflection.Emit 912 namespace, 505 authorization element, Web.config, ASP.NET, AssemblyCompanyAttribute attribute, 415 912 AssemblyCopyrightAttribute attribute, 415 AutoCheck property, Button, 711 AssemblyCultureAttribute attribute, 415 AutoEventWireUp attribute, ASP.NET, 862–63 AssemblyDescriptionAttribute attribute, 415 autogenerating SQL commands, ADO.NET, AssemblyInfo.cs file, 415 816–17 AssemblyKeyFileAttribute attribute, 416 AutoIncrement- property, ADO.NET AssemblyLoad event, System.AppDomain, 436 DataColumn object, 796 AssemblyName class, System.Reflection autoincrementing, ADO.NET, 797 namespace, 396 AutoPostBack property, ASP.NET web controls, assembly/namespace/type distinction, 22 866 AssemblyOperatingSystemAttribute attribute, 416 ■B AssemblyProcessorAttribute attribute, 416 base keyword in class creation, 156–57 AssemblyProductAttribute attribute, 416 BaseDirectory( ), System.AppDomain, 436 AssemblyRef, 394 BasePriority, ProcessThread type, 432 AssemblyResolve event, System.AppDomain, BaseStream property, BinaryReader class, 538 436 BaseStream property, BinaryWriter class, 538 AssemblyTrademarkAttribute attribute, 416 basic string operations, 123–24 AssemblyVersionAttribute attribute, 416 BeginCatchBlock( ) method, AsyncCallback delegate, multithreaded System.Reflection.Emit.ILGenerator, applications, 456–57 506 asynchronous data access, ADO.NET, 792–93 BeginExceptionBlock( ) method, asynchronous delegate call, 260–61 System.Reflection.Emit.ILGenerator, asynchronous I/O, 542–43 506 asynchronous multithreading using delegates, BeginFinallyBlock( ) method, 260–61 System.Reflection.Emit.ILGenerator, AsyncResult class, multithreaded applications, 506 457–58 BeginInvoke( ) method, multithreaded attribute-based programming applications, 453–58 assembly, module level attributes, 415 BeginInvoke( ) method, attribute key points, 412 SoapHttpClientProtocol class, 944 AttributeUsage attribute, 414 BeginLabel( ) method, C# attribute notation, 411 System.Reflection.Emit.ILGenerator, CLSCompliant attribute, 408–9 506 COM vs. .NET attributes, 408 BeginLocal( ) method, constructor parameters, 411 System.Reflection.Emit.ILGenerator, custom attributes, 412 506 description, 408 BeginScope( ) method, DllImport attribute, 409 System.Reflection.Emit.ILGenerator, early binding, 416–17 506 example of custom attributes, 413 BeginTransaction( ) method, DbConnection, extensibility, 418–24 ADO.NET, 779 late binding, 417–18 Bin, ASP.NET 2.0 subdirectories, 851–52 multiple attributes, 410–11 binary code reuse, 347 NonSerialized attribute, 409 binary opcodes, 479 Obsolete attribute, 408–9, 411 BinaryFormatter overview, 391 deserialization, 551 restricting attributes, 414 serialization, 548, 550–51 Serializable attribute, 409 BinaryReader, BinaryWriter, System.IO, 538–39 serializing example, 409–10 BinaryReader, BinaryWriter types, Visual Basic snap-in example, 420–21 input/output, System.IO, 517 WebMethod attribute, 409 BinaryReader class, 538 example, 421–22 ■INDEX 959

BinaryWriter class, 538 ChangeDatabase( ) method, DbConnection, binding DataTables to user interfaces, ADO.NET, 779 ADO.NET, 804, 806 channels, remoting, 568–69 binding element, WSDL document elements, CharacterCasing property, Textbox, 705 939 CheckAlign property, Button, 711 boxing and unboxing CheckBox AddRange( ) method, CIL code, 322 ControlCollection type, 702 generics issues, 321–22 CheckBox control, 711, 713 InvalidCastException, 322 checked compiler flag, 308 .NET 1.1 solution, 323–24 checked keyword, 307–9 .NET 2.0 solution, 104–6 Checked property, Button, 711 BrowsableAttribute, System.ComponentModel, CheckedListBox control, 714–15 746 CheckState property, Button, 711 Browser controls, 736–37 child class, description, 146 browser statisics in HTTP Request processing, child controls, System.Windows.Forms, 606 ASP.NET, 858 child forms in MDI applications, 647 BufferedStream type, input/output, System.IO, ChildRelations property, ADO.NET DataTable 517 object, 800 bugs, description, 197 CIL compiler directives, 478 Button control CIL language and programming, 477–504 AutoCheck property, 711 CIL overview, 477–78 CheckAlign property, 711 class Checked property, 711 comparison with objects and references, 179 CheckState property, 711 containment/delegation model, 146 FlatStyle property, 709, 711 definition, 69 Image property, 709 instantiation, 72 ImageAlign property, 709 member variable default values, 78 TextAlign property, 709 public interfaces, 144–45 ThreeState property, 711 types, 16 by value parameter passing, 89–90 class directive, common intermediate language (CIL), 489–90 ■C class library, definition, 347 C language deficiencies, 3 classic ASP and ASP.NET, 838, 840 C# benefits and features, 7–8 Clear( ) method C++ ADO.NET DataSet class, 795 program structure compared with C#, 65 ASP.NET HttpApplicationState members, 898 Cache, Page Type properties, ASP.NET, 856 ASP.NET HTTP Response, 860 callback interfaces ControlCollection, 702 event interface, 256–57, 259 client and server definitions, 565 overview, 255 client-activated remoting, 590–91 sink object, 256–57, 259 client-side configuration files, remoting, 585–86 two-way conversation, 255 client-side representation of XML web services, Cancel( ), DbCommand, ADO.NET, 782 952–53 CancelAsync( ) method, client-side scripting in ASP.NET, 836–37 SoapHttpClientProtocol class, 944 ClientTarget, Page Type properties, ASP.NET, CanRead, CanSeek, CanWrite, Stream class, 856 System.IO, 532 Clone( ) method, ADO.NET DataSet class, 795 CAO activation, remoting, 572–73 cloneable objects (ICloneable), 238–42 Caption property, ADO.NET DataColumn Close( ) method object, 796 BinaryReader class, 538 Cars example database, ADO.NET, 775 BinaryWriter class, 538 CaseSensitive property, ADO.NET DataSet class, Stream class, System.IO, 532 795 TextWriter, System.IO, 534 CaseSensitive property, ADO.NET DataTable CloseMainWindow( ), object, 800 System.Diagnostics.Process, 429 casting operations, 170–71 CLSCompliant attribute, 408–9 CategoryAttribute, System.ComponentModel, COBOL .NET programming language, 8 746 code comment XML format characters, 177 CausesValidation, control class property, 730 code DOM provider, 513 code libraries and assemblies, 347 960 ■INDEX

code-behind, description, ASP.NET, 842 mresources directive, 489 code-behind page model, ASP.NET, 847–49 vs. MSIL, 10 CodePage, ASP.NET <%@Page%> directive namespace directive, 489 attribute, 846 new keyword, 181 collections opcodes, 479, 495 ICollection interface, 248 overview, 11, 477 IDictionary interface, 248 peverify.exe tool, 487 IDictionaryEnumerator interface, 249 as programming language, 477 IList interface, 249 properties, 494–95 overview, 221 pushing and popping from the stack, 480 CollectionsUtil, System.Collections.Specialized, round-trip engineering, 481–85 253 saving CIL code using ildasm.exe, 481–83 colon operator, 111 stack-based programming, 480 color values, GDI+, 663 structures, 491 ColorDialog class, GDI+, 664–65 subsystem directive, 489 ColumnMapping property, ADO.NET token set of CIL, 478 DataColumn object, 796 type constructors, 494 ColumnName property, ADO.NET DataColumn using ILIDE#, 486 object, 796 using SharpDevelop, 486 Combine( ) method, variables, local, 498 System.MulticastDelegate/System virtual execution stack, 480 Delegate, 263 (CLR) ComboBox control, 716–17 file header in assemblies, 350–51 Command object, ADO.NET, 781–82 hosts Command object, ADO.NET data providers, 761 CLR versions, 446 CommandTimeout, DbCommand, ADO.NET, dotnetfx.exe, 444 782 multiple .NET Framework versions, 445 common intermediate language (CIL) .NET assembly activation under Windows advantages of learning, 477–78 XP, 444–45 assembly directive, 488 overview, 425 attributes, 479 requiredRuntime config specification, 446 benefits, 13 side-by-side execution, 445 binary opcodes, 479 specific CLR version specification, 446 C# vs. VB.NET, 11–12 mscoree.dll, 20 class directive, 489–90 mscorlib.dll, 21 code explained, 482–83 overview, 20 code labels, 483–84 Common Language Specification (CLS), 19–20 compiler flags, 485 Common Type System (CTS) compiling CIL code, 485–86 adornments, 18 compiling to specific platforms, 14 class types, 16 complete example program, 500–504 delegate types, 17 current object parameter, 499 enumeration types, 17 defining current assembly, 488 interface types, 17 directives, 478 intrinsic types, 18 enums, 491 overview, 15 externally referenced assemblies, 488 structure types, 16 field directive, 493 type members, 18 .exe compiler, 477 CompanyName property, Application class, interfaces, 490 609 iteration, 499 comparable objects (IComparable), 242–44 just-in-time (JIT) compiler, 14 CompareExchange( ) method, Interlocked type, locals directive, 498 multithreaded applications, 472 mapping C# types to CIL types, 492–93 CompareValidator control, ASP.NET, 884, 887 mapping parameters to variables, 498 compilation cycle, ASP.NET 2.0 maxstack directive, 497 multifile pages, 854–55 method parameters, 495 overview, 853 methods, 494–95 single-file pages, 853–54 mnemonics, 479 compilation element, Web.config, ASP.NET, 913 modifying CIL code, 481–85 CompilerOptions, ASP.NET <%@Page%> module directive, 488 directive attribute, 846 ■INDEX 961

compiling common intermediate language DefaultValue attribute, 747 (CIL), 485–87 Designer.cs file, 702–3 Component Object Model (COM), 5 Dock property, 755–56 concurrency, multithreaded applications, 450, dynamic positioning, 754 467–71 ErrorBlinkStyle properties, 730 conditional compile, 318–19 ErrorProviders, 729–31 configuration files, remoting, 584 events, 741 configuration inheritance, ASP.NET, 917–18 GroupBox, 711, 713 Configure( ) method, RemotingConfiguration, image processing, 739–41 580 InitializeComponent( ) method, 703 connected layer, ADO.NET, 778 Label, 704–5 Connection, DbCommand, ADO.NET, 782 ListBox, 715–16 Connection object, ADO.NET data providers, manually adding controls to forms, 700–701 761 MaskedTextBox, 707, 709 connection objects, ADO.NET, 779–80 mnemonic keys in Label, 704–5 ConnectionStringBuilder object, ADO.NET, MonthCalendar, 719–21 780–81 node images in TreeViews, 734, 736 connectionStrings element, ADO.NET overview, 699 application configuration, 774–75 Panel, 726–27 connectionStrings element, Web.config, properties, 741–44 ASP.NET, 913 RadioButton, 711, 713 ConnectionTimeout( ) method, DbConnection, tab order, 718 ADO.NET, 779 TabControl, 722–23 const keyword (constant data), 80 table and flow layout, 756–57 Constraints property, ADO.NET DataTable TabStop, TabIndex properties, 718 object, 800 TextBox, 705–7 ConstructorBuilder, System.Reflection.Emit ToolTip, 721–22 namespace, 505 TrackBar, 724–26 constructors, 70–71 TreeView, 731–36 containers for ToolStrips, Visual Studio 2005, UpDown, 727, 729 643, 645 UserControl Test Container, 743 Context property, WebService base class, 929 using custom controls, 744–45 context-agile, 441 WebControl, 736–37 context-bound, 441–42 Controls property, System.Web.UI.Control in Contraint, System.Data, ADO.NET, 764 ASP.NET, 867 contravariance, delegates, 276 cookies, ASP.NET, 909–10 control class properties, 730 coordinate systems, GDI+, 659–60 control state, state management in ASP.NET, 894 Copy( ) method, ADO.NET DataSet class, 795 ControlCollection, 702 CopyTo( ) method, FileInfo class, System.IO, 526 controls cordbg.exe command-line debugger, 40–41 adding, using Visual Studio 2005, 702–3 Count, ControlCollection, 702 animation, 743 Count property, ASP.NET HttpApplicationState ASP.NET, adding and removing, 869–70 members, 898 basic, 703–4 covariance, delegates, 275–76 Button, 709–10 Create( ) method CheckBox, 711, 713 DirectoryInfo class, 519, 522–23 CheckedListBox, 714–15 FileInfo class, System.IO, 526 ComboBox, 716–17 CreateDomain( ), System.AppDomain, 435, 437 ControlCollection, 701–2 CreateInstance( ), System.AppDomain, 436 custom, 737–43 CreateObjRef( ), System.MarshalByRefObject, appearance of, 746 572 design time attributes of, 746 CreateSubdirectory( ) method, DirectoryInfo hosts for, 744–45 class, 519, 522–23 icon, 748–49 CreateText( ) method, FileInfo class, System.IO, custom events, 741 526, 528–29 custom properties, 741–44 CreationTime property, FileSystemInfo class, DateTimePicker, 721 519 default input button, 719 csc.exe compiler, 33 DefaultEvent attribute, 748 @ symbol (response files), 39 DefaultProperty attribute, 748 command-line flags, 36 962 ■INDEX

compile parameters, 36 core objects, 761 configuration, 34–35 factory pattern, .NET 2.0, 770–74 /debug command-line flag, 41 overview, 759–61 default response file (csc.rsp), 40 DataAdapter object, ADO.NET data providers, a first C# application, 36 761 GAC utility, gacutil.exe, 35 Database property, DbConnection, ADO.NET, mscorlib.dll, 37 779 multiple external assemblies, 39 DataBind( ) method, System.Web.UI.Control in multiple source files, 38–39 ASP.NET, 867 /noconfig command-line flag, 40 DataColumn, ADO.NET, 796–97 /nostdlib command-line flag, 37 DataColumn objects, ADO.NET, 796, 798 /out command-line flag, 36 DataColumn, System.Data, ADO.NET, 764 Path, setting, 34–35 DataReader object, ADO.NET data providers, reasons for using, 34 761 /reference command-line flag, 37 DataRelation objects in multitabled DataSet referencing external assemblies, using objects, ADO.NET, 817–20 keyword, 37 DataRelation, System.Data, ADO.NET, 764 response files, 39 DataRow objects, ADO.NET, 798–801 /target command-line flag, 36 DataRow, System.Data, ADO.NET, 764 wildcard character, 38 DataRow.RowState property, ADO.NET, 799–800 CurrentContext property, Thread type, 460 DataRowState enumeration values, ADO.NET, CurrentLeaseTime, ILease interface remoting, 799 593 DataSet class, ADO.NET, 764, 794–96 CurrentPriority, ProcessThread type, 432 DataSetName property, ADO.NET DataSet class, CurrentState, ILease interface remoting, 593 795 CurrentThread property, Thread type, 460–61 Datasource property, DbConnection, ADO.NET, custom, 846–47 779 custom controls, 737–43 DataTable class, ADO.NET, 764, 800 design time appearance, 746 DataTableReader objects, ADO.NET, 802 hosts, 744–45 DataTableReader, System.Data, ADO.NET, 764 custom dialog boxes, 750–52 DataType property, ADO.NET DataColumn custom events, 741 object, 796 custom exceptions, structured exception DataView class, ADO.NET, 765, 810 handling, 209–10 DateTimePicker control, 721 custom namespaces, 133–34 DbCommand, ADO.NET, 782 custom properties, 741–44 DbConnection, ADO.NET, 779 custom type conversion DbDataAdapter members, 811 CIL special names, 306 DbDataReader object, ADO.NET, 782–83 conversions among related class types, 301–2 DbParameter, ADO.NET, 789 explicit keyword, 302–4 DbType property, ADO.NET DbParameter, 789 implicit conversions, 301 debug vs release build, 318–19 implicit keyword, 302–6 debugging and tracing, ASP.NET, 849–50 numerical converstions, 301 DecimalPlaces property, NumericUpDown, 728 custom types in XML web services, 948 decisions and relational/equality operators, custom view states, state management in 94–96 ASP.NET, 893–94 Decrement( ) method, Interlocked type, CustomAttributeBuilder, System.Reflection. multithreaded applications, 472 Emit namespace, 505 deep copy, cloneable objects (ICloneable), 242 customErrors element, Web.config, ASP.NET, default constructor, 70–71 913–15 default input button, 719 CustomValidator control, ASP.NET, 884 default keyword, generics, 333 default.aspx content page example, ASP.NET, ■D 875–76 data caching, ASP.NET, 901, 903–5 DefaultEvent attribute, controls, 748 Data property, System.Exception, 200, 206–7 DefaultEventAttribute, data providers System.ComponentModel, 746 abstracting using interfaces, 768–69 DefaultProperty attribute, controls, 748 asynchronous, .NET 2.0, 792–93 DefaultPropertyAttribute, command builder type, 816 System.ComponentModel, 746 DefaultValue attribute, controls, 747 ■INDEX 963

DefaultValue property, ADO.NET DataColumn Directory type, System.IO, 523–24 object, 796 DirectoryInfo class DefaultValueAttribute, Create( ), CreateSubdirectory( ) methods, System.ComponentModel, 746 519, 522–23 DefaultWsdlHelpGenerator.aspx, 925–26 Delete( ) method, 519 DefineEnum( ) method, ModuleBuilder type, GetDirectories( ) method, 519 510 GetFiles( ) method, 520–22 DefineResource( ) method, ModuleBuilder type, MoveTo( ) method, 520 510 Parent property, 520 DefineType( ) method, ModuleBuilder type, 510 Root property, 520 delayed digital signing of assemblies, 375–76 DirectoryName, FileInfo class, System.IO, 526 delegates dirty windows, Paint event, GDI+, 656 asynchronous call, 260–61 DISCO web service UDDI directory, 921 CIL code for simple example, 264 disconnected layer, ADO.NET, 793 compared with C-style callbacks, 259 DispatchMessage( ) method, remoting complex example, 270–71 ChannelServices, 579 contravariance, 276 disposable objects covariance, 275–76 code example, 191 delegate keyword, 259 Dispose( ) method, 191 description, 259 IDisposable interface, 191–93 example, 266–68 disposing Graphics objects, GDI+, 658–59 information in, 259 dll, 485 multicast, 262, 268–70 DLL hell, 5 and multithreaded applications, 451, 453 DllImport attribute, 409 NullReferenceException, 267–68 /doc compiler flag, 177 overview, 255 Dock property, controls, 755–56 as parameters, 271–73, 275 DockStyles enumeration values, 755 simple example, 263–64 Document Object Model (DOM), ASP.NET, 836 synchronous call, 260 documentation of source code, with XML, type safe, 264–65 175–77 types, 17 DoEvents( ) method, Application class, 609 delegation, description, 160 DomainUnload event, System.AppDomain, Delete( ) method 436, 439–40 ADO.NET DataRow object, 799 DomainUpDown, 728 DirectoryInfo class, 519 dot operator and references, 180 FileInfo class, System.IO, 526 dotnetfx.exe, .NET runtime deployment, 29 DeleteCommand property in updating, download cache, 352 ADO.NET, 815 DriveInfo class, System.IO, 517, 524–25 deleting dynamic assemblies records, ADO.NET, 787 code DOM provider, 513 rows, ADO.NET, 806–7 ConstructionBuilder example, 511–12 deployment, .NET runtime, 29 definition, 505 derived class, description, 146 emitting a method, 512 DescriptionAttribute, emitting type and member variables System.ComponentModel, 746 examples, 510 Designer.cs file, 702–3 overview, 477 detailed content page example, ASP.NET, vs. static assemblies, 504–5 881–83 using dynamically generated assembly, developing software, 3–5 512–13 device coordinates, GDI+ coordinate systems, dynamic loading, 402–3 659–60 dynamic positioning, controls, 754–55 dialog boxes, custom, 750–52 dynamic web service discovery using DISCO, differences, classes, objects, references, 179 921 digital signatures, and strong names, 371, 373 Direction property, ADO.NET DbParameter, 789 ■E directives, compiler, 478 ECMA standardization, .NET Framework, 29 Directory edit processing members, ADO.NET DataRow DirectoryInfo types, input/output, object, 799 System.IO, 517–19 Eiffel .NET programming language, 8 FileInfo class, System.IO, 526 964 ■INDEX

Emit( ) method, System.Reflection.Emit. event handling in ToolStrips, Visual Studio 2005, ILGenerator, 506 643 EmitCall( ) method, System.Reflection.Emit. event interface, 256–57, 259 ILGenerator, 506 EventBuilder, System.Reflection.Emit emitting dynamic assembly, 506–13 namespace, 505 Emitting HTML, ASP.NET, 860 EventInfo class, System.Reflection namespace, EmitWriteLine( ) method, 396 System.Reflection.Emit.ILGenerator, events 506 adding to custom controls, 741 EnableThemeing property, compared with delegates, 277 System.Web.UI.Control in ASP.NET, 867 event keyword, 277 EnableTheming, ASP.NET <%@Page%> example, 277 directive attribute, 846 explanation, 278–79 EnableViewState, ASP.NET <%@Page%> listening to incoming events, 279–80 directive attribute, 846 Microsoft recommended pattern, 281–82 EnableVisualStyles( ) method, Application class, overview, 255 609 registration, 279–81 encapsulation exception handling, structured accessor (get) and mutator (set) methods, advantages, 199 148 application-level exceptions, 208–10 black box programming, 148 bugs, description, 197 class properties, 149–53 catching exceptions, 203–4 description, 145 configuring exception state, 204 get, set keywords for class properties, 149–50 custom exceptions, 209–10 get, set properties vs. accessor and mutator entities used in, 199 methods, 150–53 exceptions, description, 197 public fields and data validation, 148 finally block, 215–16 read-only class properties, 153–54 generic exceptions, 202, 213 static class properties, 154–55 inner exceptions, 214–15 visibility of get/set statements, 153 keywords used, 199 write-only class properties, 153–54 multiple exceptions, 212–13 End( ) method, ASP.NET HTTP Response, 860 overview, 197 EndExceptionBlock( ) method, possible .NET exceptions, 216 System.Reflection.Emit.ILGenerator, rethrowing exceptions, 214 506 simple example, 200, 202–4 EndInvoke( ) method, multithreaded System.Exception, 199–200, 202–4 applications, 453–54 system-level exceptions, 208 EndInvoke( ) method, SoapHttpClientProtocol System.Serializable attribute, 211 class, 944 template, exception, 211 EndScope( ) method, throwing an exception, 202–3 System.Reflection.Emit.ILGenerator, traditional exception handling, 198 506 try/catch block, 203–4 EnforceConstraints property, ADO.NET DataSet typed exceptions, 217 class, 795 unhandled exceptions, 217 EnumBuilder, System.Reflection.Emit user errors, description, 197 namespace, 505 Visual Studio 2005 features, 216, 218–19 enumerable types (IEnumerable and Exchange( ) method, Interlocked type, IEnumerator), 235–37 multithreaded applications, 472 enumerating controls with Panel control, exe compile target, 607 ASP.NET, 867–68 ExecutablePath property, Application class, 609 enumeration types, 17 ExecuteAssembly( ), System.AppDomain, 436 enums, 107–10, 491 ExecuteNonQuery( ), DbCommand, ADO.NET, Equals( ), System.Object instance-level 782 member, 111 ExecuteReader( ), DbCommand, ADO.NET, 782 Error event, ASP.NET, 863–64 ExecuteScalar( ), DbCommand, ADO.NET, 782 error processing members, ADO.NET DataRow ExecuteXmlReader( ), DbCommand, ADO.NET, object, 798 782 ErrorBlinkStyle properties, controls, 730 Exit( ) method, Application class, 609 ErrorProviders, 729–31 ExitCode, System.Diagnostics.Process, 428 escape characters, summary, 124 ExitTime, System.Diagnostics.Process, 428 ■INDEX 965

explicit casting, 170–71, 224–25 life cycle, 619 explicit interface implementation, 229–31 methods, 618 explicit keyword, custom type conversion, properties, 618 302–4 form control declarations, ASP.NET, 847 Expression property, ADO.NET DataColumn form data, access in ASP.NET, 858–59 object, 797 form inheritance, 752–54 eXtensible Markup Language. See XML Form object inheritance chain, 612 Extension property, FileSystemInfo class, 519 Form, System.Windows.Forms, 606 externally referenced assemblies, in common Format( ) method, System.Enum, 109 intermediate language (CIL), 488 forms, 605 forms controls, 699 ■F Forth .NET programming language, 8 field directive, common intermediate language Fortran .NET programming language, 8 (CIL), 493 FullName property, FileSystemInfo class, 519 FieldBuilder, System.Reflection.Emit fully qualified type names, 134–36 namespace, 505 FxCop development tool, 62 FieldInfo class, System.Reflection namespace, 396 ■G File class, System.IO, 529, 531 GAC, default location in Windows, 25, 371 File, FileInfo types, input/output, System.IO, GAC utility, gacutil.exe, 35 518–19 garbage collection FileAttributes enum, FileSystemInfo class, 521 AddMemoryPressure( ) method, 185 FileInfo class, System.IO, 526–29 AddRef( ) not required, 181 FileStream class, System.IO, 532–33 application domain, 188 FileStream type, input/output, System.IO, 518 application roots, 182 FileSystemInfo class, 519 code example, 185–87 FileSystemWatcher class, System.IO, 540–41 Collect( ) method, 185–87 FileSystemWatcher type, input/output, CollectionCount( ) method, 185 System.IO, 518 compared with C++, 181 Fill( ) method, ADO.NET, data adapter, 811 finalizable objects, 188 filters, ADO.NET, 807–8 finalization details, 191 finalizable objects, 188 forcing, 186–87 finalization details, 191 GetGeneration( ) method, 185 finalize( ), overriding, 189–90 GetTotalMemory( ) method, 185 Finalize( ), System.Object instance-level MaxGeneration property, 185 member, 112 memory leaks, 72 finally block, structured exception handling, object generations, 184 215–16 object graph use, 182–83 FindMembers( ) method, System.Type class, overriding finalize( ), 189–90 397 overview, 179 fixed keyword, 315 PInvoke, 189 FlatStyle property, Button, 709, 711 reachable objects, 180 FlowLayoutPanel, controls, 756–57 Release( ) not required, 181 Flush( ) method SuppressFinalize( ) method, 185 ASP.NET HTTP Response, 860 System.GC, 185 BinaryWriter class, 538 threads suspended, 182 Stream class, System.IO, 532 timing of, 181 TextWriter, System.IO, 534 unmanaged resources, 185, 189–90, 193 FontDialog class, GDI+, 671–72 WaitForPendingFinalizers( ) method, 185–86 fonts, GDI+, 665 when heap objects are removed, 180, 182 enumerating, 669–70 GDI+ faces and sizes, 667, 669 color values, 663 families, 666–67 ColorDialog class, 664–65 for loop, 92 coordinate systems, 659–60 forcing garbage collection, 186–88 core namespaces, 649 foreach loop, 93 custom point of origin, 662 Form class disposing graphics objects, 658–59 events, 618–19 FontDialog class, 671–72 example program, 619–20 fonts, 665 966 ■INDEX

enumerating, 669–70 435 faces and sizes, 667, 669 GetDirectories( ) method, DirectoryInfo class, families, 666–67 519 hit testing nonrectangular images, 688, 690 GetDomain( ), GetDomainD( ) methods, Thread hit testing rendered images, 687–88 type, 460 methods in FontFamily, 666 GetEnumerator( ) method, ControlCollection, namespaces, 650 702 overview, 649 GetEvents( ) method, System.Type class, 396 PageUnit property, custom unit of measure, GetFactory( ) method, ADO.NET, 771 661–62 GetFields( ) method, System.Type class, 396 Pen properties, 673 GetFiles( ) method, DirectoryInfo class, 520–22 Pens collection, 673 GetHashCode( ), System.Object instance-level PictureBox type, 684–86 member, 111 System.Drawing namespace, 650 GetInterfaces( ) method, System.Type class, 396 System.Drawing.Brush, 677 GetInvocationList( ) method, HatchBrush, 678–79 System.MulticastDelegate/System LinearGradientBrush, 681 Delegate, 263 TextureBrush, 679–80 GetLifetimeServices( ), System.Drawing.Drawing2D, 672 System.MarshalByRefObject, 572 Pen types, 673–74 GetMembers( ) method, System.Type class, 396 Pens, LineCap, 675–76 GetMethods( ) method, System.Type class, 396 System.Drawing.Font, 665 GetName( ) method, System.Enum, 109 System.Drawing.Graphics class, 653 GetNestedTypes( ) method, System.Type class, System.Drawing.Image, 682, 684 396 unit of measure, 660 GetObjectData( ) method, serialization, 558–60 generic method GetParentRelations( ) method, ADO.NET example code, 329–32 DataSet class, 795 type parameter omission, 330–32 GetProcesses( ), System.Diagnostics.Process, generic structures, classes, 332–33 429 generics GetProperties( ) method, System.Type class, 396 base classes, 339–40 GetRegisteredActivatedClientTypes( ) method, boxing and unboxing issues, 321–25 RemotingConfiguration, 580 constraining type parameters using where, GetRegisteredWellKnownClientTypes( ) 335–38 method, RemotingConfiguration, 580 custom generic collections, 334–35 GetRegisteredWellKnownServiceTypes( ) default keyword, 333 method, RemotingConfiguration, 580 delegates, 341–42 GetSchema( ) method, DbConnection, delegates using .NET 1.1, 342–43 ADO.NET, 779 generic methods, 329–32 get/set interfaces, 340–41 accessor and mutator methods comparision, lack of operator constraints, 338–39 150–52 nested delegates, 343 visibility of statements, 153 overview, 321 GetType( ) method System.Collections.Generic.List<>, 325–26 System.Object class, 397 uses of, 321–25 System.Object instance-level member, 111 Gephardt, Sean, 45 System.Type class, 397 GET and POST, ASP.NET, 837–38 GetUnderlyingType( ) method, System.Enum, GET data type, 940 109 GetAssemblies( ), System.AppDomain, 436 GetUrlsForObject( ) method, remoting GetChanges( ) method, ADO.NET DataSet class, ChannelServices, 579 795 GetValues( ) method, System.Enum, 109 GetChannel( ) method, remoting (GAC) ChannelServices, 579 and assemblies, 348 GetChildRelations( ) method, ADO.NET DataSet default location in Windows, 25, 371 class, 795 internal composition, 382, 384 GetConstructors( ) method, System.Type class, overview, 25 396 Global.asax file, ASP.NET, 894–96 GetCurrentProcess( ), globalization element, Web.config, ASP.NET, 913 System.Diagnostics.Process, 429 Globally Unique Identifier (GUID), 240–42, 371, GetCurrentThreadId( ), System.AppDomain, 373 ■INDEX 967

Graphics object with no Paint event, GDI+, 657 Id, System.Diagnostics.Process, 428 GraphicsPath class, methods, GDI+, 689 IDataAdapter, System.Data, ADO.NET, 765 GroupBox control, 711, 713 IDataParameter, System.Data, ADO.NET, 765 GUI programming IDataReader, System.Data, ADO.NET, 765 overview, 605 IDbCommand interface, ADO.NET, 766 Visual Studio 2005, 621 IDbCommand, System.Data, ADO.NET, 765 IDbConnection interface, ADO.NET, 765 ■H IDbDataAdapter, IDataAdapter interface, Handle, System.Diagnostics.Process, 428 ADO.NET, 767 HandleCount, System.Diagnostics.Process, 428 IDbDataAdapter, System.Data, ADO.NET, 765 has-a relationship code example, 159–60 IDbDataParameter, IDataParameter interface, HasChanges( ) method, ADO.NET DataSet ADO.NET, 766 class, 795 IDbDataReader, IDataReader interface, HasControls( ) method, System.Web.UI.Control ADO.NET, 767–68 in ASP.NET, 867 IDbTransaction interface, ADO.NET, 765 HasErrors property, ADO.NET DataSet class, IdealProcessor, ProcessThread type, 432 795 identity, private assemblies, 365 Hashtable System.Collections class type, 250 IDictionary System.Collections interface, 247 HatchBrush, System.Drawing.Brush, 678–79 IDictionaryEnumerator System.Collections heap, and reference types, 98 interface, 247 HelpLink property, System.Exception, 200, 206 IDisposable interface, unmanaged resources, Hexadecimal property, NumericUpDown, 728 191–93 historical overview of programming Idle event, Application class, 609 C++/MFC, 4 IEnumerable System.Collections interface, 247 Component Object Model (COM), 5 IEnumerator, IEnumerable interfaces, indexer C/Win32, 3 technique, 290 Java/J2EE, 4 IEnumerator System.Collections interface, 247 Visual Basic 6.0, 4 if/else statement, 94 Windows DNA, 5 IHashCodePRovider System.Collections hit testing interface, 247 nonrectangular images, 688, 690 IIS rendered images, 687–88 default web site, 830 HTML deployment, XML web service, 925 and ASP.NET, overview, 832 description, 830 document structure, 833 virtual directories, 831 form development, 833 IKeyComparer System.Collections interface, HTTP channel, remoting, 568 247 HTTP Request, ASP.NET, 858 ilasm.exe compiler, common intermediate HTTP Request processing, ASP.NET, 857–59 language (CIL), 477 HTTP Response processing, ASP.NET, 859–61 ildasm exploration of manifest, 357 HTTP transport of web service, 922 ILease interface remoting, 593 HttpApplication members, ASP.NET, 897 ILGenerator, System.Reflection.Emit HttpApplication type overview, 889 namespace, 505 HttpApplicationState members, ASP.NET, 898 IList System.Collections interface, 247 HybridDictionary, image processing in custom controls, 739–41 System.Collections.Specialized, 253 Image property, Button, 709 Image type core members, 682 ■I ImageAlign property, Button, 709 IasyncResult interface, 260–61 images in ToolStrips, Visual Studio 2005, 641–43 ICollection System.Collections interface, 247–48 implicit cast, 171 ICollection System.IDictionaryEnumerator implicit keyword, custom type conversion, interface, 249 302–6 ICollection System.Idictionaryinterface, 248 Increment( ) method, Interlocked type, ICollection System.IList interface, 249 multithreaded applications, 472 IComparer System.Collections interface, 247 Increment property, NumericUpDown, 728 icons, custom controls, 748–49 indexer technique Id, ProcessThread type, 432 CIL internal code, 292 ID property, System.Web.UI.Control in ASP.NET, example, 290–91 867 IEnumerator, IEnumerable interfaces, 290 multidimensional collections, 293 968 ■INDEX

overview, 289 interface keyword, 221 System.Collection.ArrayList, 290–91 interfaces System.Collections.Specialized. abstract base class comparison, 224 ListDictionary, 291–92 in arrays, 228 this[ ] syntax, 290–91 cloneable objects (ICloneable), 238–42 inheritance, 146, 752–54 colon operator, 222 base keyword in class creation, 156–57 common intermediate language (CIL), 490 colon operator, 155 comparable objects (IComparable), 242–44 containment/delegation inheritance model, custom interface example, 221–22 159–60 custom properties and sort types, 246 description, 146 and data providers, ADO.NET, 768–69 has-a relationship code example, 159–60 deep copy, 242 is-a relationship code example, 155–56 definition, 221 multiple base classes not allowed, 157 determining using as keyword, 225 picker utility, 753–54 determining using explicit cast, 224–25 protected keyword, 158 determining using is keyword, 225–26 sealed classes, 159, 164 enumerable types (IEnumerable and inheritance chain, page type in ASP.NET, 855–56 IEnumerator), 235–37 Inherits, ASP.NET <%@Page%> directive explicit implementation, 229–31 attribute, 846 hierarchies, 232 Init, ASP.NET Page events, 862 implementing, 223 InitializeComponent( ) method, 703 invoking objects based on, 224 InitializeLifetimeServices( ), multiple base interfaces, 233 System.MarshalByRefObject, 572 multiple sort orders (IComparer), 245–46 InitialLeaseTime, ILease interface remoting, 593 name clashes, 229–31 InnerException property, System.Exception, overview, 221 200 shallow copy, 238–41 in-place editing example, ASP.NET, 879–80 struct, derive from System.ValueType, 222 input/output, System.IO System.Collections interfaces, 247 asynchronous I/O, 542–43 System.Object base class, 222 BinaryReader, BinaryWriter, 538–39 types, 17 BinaryReader, BinaryWriter types, 517 using as a parameter, 226–27 BufferedStream type, 517 using as a return value, 228 Directory, DirectoryInfo types, 517–19 Visual Studio 2005, 234–35 Directory type, 523–24 Interlocked type, multithreaded applications, DriveInfo class, 524–25 472 DriveInfo type, 517 Interlocked type, System.Threading File class, 529, 531 Namespace, 459 File, FileInfo types, 518–19 Intermediate Language Disassembler utility FileInfo class, 525 (ildasm.exe) FileStream class, 532–33 CIL code display, 27 FileStream type, 518 icons, 26 FileSystemWatcher class, 518, 540–41 manifest display, 28 MemoryStream type, 518 overview, 26 namespace description, 517 type metadata display, 28 overview, 517 intermediate language (IL), 10 Path type, 518 internal access modifier, 77 reading from a text file, 535 Interrupt( ) method, Thread type, 460 Stream class, 531 intrinsic types in CTS, VB.NET, C#, C++, 18 StreamReader, StreamWriter, 533 Invalidate( ) method and Paint event, GDI+, StreamWriter, StreamReader types, 518 656–57 StringReader, StringWriter, 536–37 InvalidCastException, boxing and unboxing, 322 StringWriter, StringReader types, 518 inventory content page example, ASP.NET, writing to a text file, 534–35 877–78 InsertCommand property in updating, Invoke( ) method, SoapHttpClientProtocol ADO.NET, 814 class, 944 inserting records, ADO.NET, 786 InvokeAsync( ) method, installing .NET 2.0 Framework SDK, 33 SoapHttpClientProtocol class, 945 InterceptArrowKeys property, UpDownBase, InvokeMember( ) method, System.Type class, 728 397 ■INDEX 969

IPC channel, remoting, 568, 583 constant data, 80 is keyword, 107 constructors, 70–71 determining interface support, 225–26 custom namespaces, 133–34 determining type, 172 decisions, 94–96 is-a relationship code example, 155–56 default constructor, 70–71 IsAbstract, System.Type class, 396 defining classes and creating objects, 69–70 IsAlive method, Thread type, 460 destroying objects, 72 IsArray, System.Type class, 396 enums, 107–10 IsBackground method, Thread type, 460 escape characters, 124 IsClass, System.Type class, 396 for, foreach looping, 67 IsCOMObject, System.Type class, 396 foreach loop, 93 IsDefined( ) method, System.Enum, 109 fully qualified type names, 134–36 IsEnum, System.Type class, 396 garbage collection, 72 ISerializable interface, 557 GetCommandLineArgs( ), 67 IsGenericParameter, System.Type class, 396 internal vs external constant data, 81 IsGenericTypeDefinition, System.Type class, is keyword, 107 396 iteration, 92–93 IsInterface, System.Type class, 396 local variable default values, 79 IsNestedPrivate, System.Type class, 396 for loop, 92 IsNestedPublic, System.Type class, 396 Main( ) method, 66 IsNull( ) method, ADO.NET DataRow object, member variable initialization syntax, 79–80 799 member visibility, 76–78 IsNullable property, ADO.NET DbParameter, method parameter modifiers, 89 789 namespaces, default Visual Studio 2005, 138 IsPostBack property in HTTP Request nested namespaces, 137–38 processing, ASP.NET, 859 .NET formatting flags, 75–76 IsPrimitive, System.Type class, 396 new keyword, 69–70 IsSealed, System.Type class, 396 nullable types, 131, 133 IsValueType, System.Type class, 396 objects, definition, 69 IsWellKnownClientType( ) method, overview, 65 RemotingConfiguration, 580 parameter-passing, 89–91 ItemArray, ADO.NET DataRow object, 798 parsing values from string data, 121 Items property, DomainUpDown, 728 passing reference types by reference, 102 iteration, 92–93 passing reference types by value, 101–2 iteration, common intermediate language read-only fields, 82–83 (CIL), 499 relational/equality operators, 94–96 static classes, 88 ■J static constructors, 86–87 Java/J2EE language deficiencies, 4 static data, 84–86 Jitter, just-in-time (JIT) compiler, 14 static keyword, 83–88 Join( ) method, Thread type, 460 static methods, 84 static read-only fields, 83 ■K String.Concat( ) method, 124 key, CIL compiler flags, 485 strings, 124 Kill( ), System.Diagnostics.Process, 429 System data types, 117–20 System.Array, 130 ■L System.Boolean, 120 Label control, 704–5 System.Char, 121 language fundamentals System.Console class, 73–75 ?? operator, 133 System.DateTime, 122 arrays, 127–30 System.Environment class, 68–69 basic program structure, 65–66 System.Nullable, 132 basic string operations, 123–24 System.Object, 111–17 boxing and unboxing, 104–6 System.String data type, 123 C++ program structure compared with C#, 65 System.Text.StringBuilder, 126–27 class definition and instantiation, 72 System.TimeSpan, 122 class member variable default values, 78 System.ValueType, 97 classes, definition, 69 type visibility, 78 command-line arguments, 67–68 unboxing custom value types, 106 user-defined type (UDT), definition, 69–70 970 ■INDEX

using aliases, 136–37 MapPath( ) method, ASP.NET HTTP Request, 858 value types and reference types, 96–100, mapping 103–4 C# types to CIL types, 492–93 verbatim strings, 125 DBMS names, ADO.NET, 813 while, do/while loops, 93 parameters to variables, CIL, 498 LargeChange property, TrackBar control, 724 marshaling, remoting, 570 LastAccessTime property, FileSystemInfo class, MaskedTextBox control, 707, 709 519 master pages example, ASP.NET, 872–73 LastWriteTime property, FileSystemInfo class, MasterPageFile, ASP.NET <%@Page%> directive 519 attribute, 846 late binding MasterPageFile, Page Type properties, ASP.NET, description, 406 856 invoking methods with no parameters, 407 Maximum, Minimum properties, TrackBar invoking methods with parameters, 407–8 control, 724 overview, 391 Maximum property, NumericUpDown, 728 System.Activator class, 406–7 maxstack directive, common intermediate layout components, System.Windows.Forms, language (CIL), 497 606 MBV remoting, 586–89 layout, controls, 756–57 client assembly, 588–89 lease-based lifetimes, remoting, 592–97 server assembly, 587–88 Length, FileInfo class, System.IO, 526 MDI applications, Visual Studio 2005, 646 Length( ) method, Stream class, System.IO, 532 member variable initialization syntax, 79–80 life cycle of a web page, ASP.NET, 861–63, 865 member visibility, 76–78 LinearGradientBrush, System.Drawing.Brush, MemberInfo class, System.Reflection 681 namespace, 396 ListBox control, 715–16 MemberwiseClone( ), System.Object instance- ListDictionary, System.Collections.Specialized, level member, 112 253 memory allocation (unsafe), 314–15 Load( ), System.AppDomain, 436, 438 memory management Load, ASP.NET Page events, 862 first rule, 180 local variable default values, 79 second rule, 182 LocalBuilder, System.Reflection.Emit third rule, 189 namespace, 505 fourth rule, 192 locals directive, common intermediate Finalize( ) vs. IDisposable interface, 194–95 language (CIL), 498 resource wrapper Microsoft code example, Lock( ) method, ASP.NET HttpApplicationState 194–95 member, 898 memory management in CIL, 181–82 lock token and multithreaded applications, MemoryStream type, input/output, System.IO, 469–71 518 locking memory (unsafe), 315 menu components, System.Windows.Forms, looping, 92–93 606 Lutz Roeder’s Reflector for .NET development menu control example, ASP.NET, 873 tool, 62 Menu selection prompts, Visual Studio 2005, 639 ■M menu sytems, Visual Studio 2005, 634, 636–37 machine.config, 388 Merge( ) method, ADO.NET DataSet class, 795 MachineName, System.Diagnostics.Process, message element, WSDL document elements, 428 938 Main( ) method, multithreaded applications, Message property, System.Exception, 200, 210 457 metadata and type reflection, 392, 398–402 MainModule, System.Diagnostics.Process, 428 method group conversions, C# 2005, 285–86 maintaining session data, ASP.NET, 906–8 method hiding, description, 169–70 MainWindowHandle, method parameter modifiers, 89 System.Diagnostics.Process, 428 Method property, MainWindowTitle, System.Diagnostics.Process, System.MulticastDelegate/System 428 Delegate, 263 managed code, 8 MethodBuilder, System.Reflection.Emit managed heap, 180–84 namespace, 505 manifest, assemblies, 348 MethodInfo class, System.Reflection namespace, 396 ■INDEX 971

methods synchronization attribute, 472–73 common intermediate language (CIL), synchronizing threads, 455–56 494–95 synchronous operations, 451, 453 in FontFamily, GDI+, 666 System.Threading Namespace, 459 Microsoft Express IDEs, overview, 50 System.Threading.Interlocked type and Microsoft recommended event pattern, 281–82 synchronization, 471–72 Minimum property, NumericUpDown, 728 Thread class, 449 mnemonic keys in Label control, 704–5 thread relationship to process, AppDomain, mnemonics, CIL, 479 and context, 449–51 modifying application data, ASP.NET, 899–900 thread-volatile operations, 450 modifying tables, Command object, ADO.NET, Timer callbacks, 473–74 784–86 Mutex type, System.Threading Namespace, Module class, System.Reflection namespace, 459 396 module directive, common intermediate ■N language (CIL), 488 name clashes in interfaces, 229–31 module set for a process example code, 432–33 Name, FileInfo class, System.IO, 526 ModuleBuilder, System.Reflection.Emit Name method, Thread type, 460–61 namespace, 505, 509–10 Name property, FileSystemInfo class, 519 Modules, System.Diagnostics.Process, 428 namespace directive, common intermediate Monitor type, System.Threading Namespace, language (CIL), 489 459 namespace keyword, 133–34 MonthCalendar control, 719–21 namespaces, 22–25 MoveTo( ) method namespaces, default Visual Studio 2005, 138 DirectoryInfo class, 520 NameValueCollection, FileInfo class, System.IO, 526 System.Collections.Specialized, 253 mresources directive, common intermediate Nant development tool, 62 language (CIL), 489 navigating between related tables, ADO.NET, mscoree.dll, Common Language Runtime 820–21 (CLR), 20–21, 425 NDoc development tool, 62 MSIL vs. CIL, 10 nested namespaces, 137–38 multicast delegate call, 262 nested type definitions, 161–62 multicasting, delegates, 268–70 .NET 1.x controls in Visual Studio 2005, 623 multifile assemblies, 11, 352, 362–65 .NET Framework multiple base classes not allowed, 157 base class libraries, 7 multiple base interfaces, 233 basic building blocks overview, 6 multiple exceptions, 212–13 Common Language Infrastructure(CLI), multiple .NET Framework versions, 445 29–30 multiple result sets, DbDataReader object, common language runtime (CLR) overview, 6 ADO.NET, 784 Common Language Specification (CLS) multiple sort orders (IComparer), 245–46 overview, 6 multitabled DataSet objects, ADO.NET, 817–20 Common Type System (CTS) overview, 6 multithreaded applications Configuration utility, 369–70, 382 AsyncCallback delegate, 456–57 core features, 6 asynchronous operations, 453–54 ECMA standardization, 29 AsyncResult class, 457–58 interoperability with COM, 6 atomic operations, 450 , 30 BeginInvoke( ), 453–54, 456–58 .NET-aware programming languages, 8–9 CLR thread pool, 475–76 non-Windows platforms, 29–30 concurrency, 450, 467–70 overview, 6 delegate review, 451, 453 Portable .NET, 30 EndInvoke( ), 453–54 Virtual Execution System (VES), 29 execution speed vs. responsiveness, 465 web links to .NET-aware languages, 8–9 foreground vs. background threads, 466–67 .NET runtime deployment, 29 lock keyword and synchronization, 469–71 .NET type metadata Main( ) method, 457 initial example, 14–15 overview, 449 overview, 14 secondary thread creation, 462–63 .NET, why learn it, 3 state data, 458 netmodule file extension, 352, 362–64 synchronization, 450 972 ■INDEX

new keyword, 69–70 OnSerializedAttribute, serialization, 557 CIL implementation, 181 OnSerializingAttribute, serialization, 557 references, 180 opcodes, CIL, 479, 495–97 NewLine, TextWriter, System.IO, 534 OpCodes, System.Reflection.Emit namespace, newobj CIL instruction, 181 505 noautoinherit, 485, CIL compiler flags Open( ) method, FileInfo class, System.IO, node images in TreeViews, 734, 736 526–27 nonrectangular images, GDI+, 688, 690 OpenRead( ) method, FileInfo class, System.IO, nullable types, 131, 133 526, 528 NullReferenceException, delegates, 267–68 OpenText( ) method, FileInfo class, System.IO, numeric System data types, 120 526, 528 NumericUpDown, 728 OpenWrite( ) method, FileInfo class, System.IO, Nunit development tool, 62 526, 528 operator constraints, lack of with generics, ■O 338–39 Oberon programming language, 8 operator overloading object contexts binary operators, 294–95 boundaries, 440 C# to CIL special names index, 299 context 0, 440 cautions, 301 context-agile, 441 CIL internal code, 298–99 context-bound, 441–42 comparison operators, 297–98 overview, 425 description, 293 program example, 442–43 equality operators, 296–97 object generations, 184 operation overloading in other languages, object graph 299–300 definition, 546 operator keyword, 295 garbage collection, 182–83 operators that can be overloaded, 293 reachable objects, 182–83 overview, 289 relationships, 547 shorthand assignment operators, 295 simple example, 546–47 unary operators, 296 object keyword, boxing, 104–6 OptionalFieldAttribute, serialization, 557 object lifetime Ordinal property, ADO.NET DataColumn object generations, 184 object, 797 overview, 179 Orientation property, TrackBar control, 724 System.GC, 185 origin point, GDI+, 662 when heap objects are removed, 180, 182 out method parameter modifier, 89–90 object oriented programming, 317–19 outer variables, 284–85 class, description, 139 output, CIL compiler flags, 485 class public interfaces, 144–45 overflow/underflow, 307–9 constructors, example Employee class, 140 override keyword, description, 163–64 example Employee class, 139, 141 forwarding constructor calls using this, 143 ■P has-a relationship, 146 page coordinates, GDI+ coordinate systems, 659 is-a relationship, 146 Page events, ASP.NET, 862 method overloading, 141 Page property, System.Web.UI.Control in overview, 139 ASP.NET, 867 Pillars of OOP, 4 Page Type properties, ASP.NET, 856–57 encapsulation, 145, 148 PageUnit property, custom unit of measure, inheritance, 146, 155 GDI+, 661–62 polymorphism, 147, 162 Paint event, GDI+, 656 state of a class instance, description, 139 Panel control, 726–27 this keyword, 142–43 parameter, interface used as, 226–27 ObjectIDGenerator, serialization, 557 Parameter object, ADO.NET data providers, 761 objects ParameterBuilder, System.Reflection.Emit definition, 69 namespace, 505 differences from classes and references, 179 ParameterInfo class, System.Reflection Obsolete attribute, 408–9 namespace, 396 OnDeserializedAttribute, serialization, 557 parameterized command objects, ADO.NET, OnDeserializingAttribute, serialization, 557 788 ■INDEX 973

ParameterizedThreadStart delegate, primary thread, 426 System.Threading Namespace, 459, Priority method, Thread type, 460, 462 462–66 PriorityBoostEnabled, ParameterName property, ADO.NET System.Diagnostics.Process, 429 DbParameter, 789 PriorityClass, System.Diagnostics.Process, 429 parameter-passing, 89–91 PriorityLevel, ProcessThread type, 432 Parameters, DbCommand, ADO.NET, 782 private access modifier, 77 params method parameter modifier, 89, 91 private assemblies parent forms in MDI applications, 646 configuration, 366, 368 Parent property description, 365 DirectoryInfo class, 520 identity, 365 System.Web.UI.Control in ASP.NET, 867 probing, 366, 368 Parse( ) method, System.Enum, 109 Process class, System.Diagnostics namespace, parsing values from string data, 121 428 partial type modifier, 173–74 process identifier (PID), 425, 429–31 passing reference types, 101–2 processes PasswordChar property, Textbox, 705 definition, 425 Path, setting, 35 module set example code, 432–33 Path type, input/output, System.IO, 518 overview, 425 Peek( ) method, TextReader, System.IO, 535 process manipulation example code, 429–30 PeekChar( ) method, BinaryReader class, 538 starting and stopping example code, 434–35 Pen properties, GDI+, 673 System.Diagnostics namespace, 427 Pens collection, GDI+, 673 thread examination example code, 430–31 persistence of cookies, ASP.NET, 909–10 ProcessExit event, System.AppDomain, 436, persisting datasets as XML, ADO.NET, 803 439–40 peverify.exe tool, compiling common ProcessModule type, System.Diagnostics intermediate language (CIL), 487 namespace, 428 philosophy of .NET, overview, 3 ProcessModuleCollection, System.Diagnostics PictureBox type, 684–86 namespace, 428 Pillars of OOP, 4 ProcessName, System.Diagnostics.Process, 429 encapsulation, 145, 148 ProcessorAffinity, ProcessThread type, 432 inheritance, 146, 155 ProcessStartInfo, System.Diagnostics polymorphism, 147, 162 namespace, 428 pixel unit of measure, GDI+, 660 ProcessThread, System.Diagnostics namespace, Platform Invocation Services (PInvoke), 6 428 pointer types and operators ProcessThread type, 432 & operator, 312–13 ProcessThreadCollection, System.Diagnostics * operator, 312–13 namespace, 428 > operator, 314 ProductName property, Application class, 609 example, swap function, 313 ProductVersion property, Application class, 609 field access, 314 programming. See historical overview of table of operators, 310 programming Point(F) type, System.Drawing namespace, properties 651–52 adding to custom controls, 741–44 polygons, GDI+, 688, 690 common intermediate language (CIL), polymorphism 494–95 abstract classes, 164, 166 internal representation, 152–53 abstract methods, 166–69 PropertyBuilder, System.Reflection.Emit description, 147 namespace, 505 method hiding, 169–70 PropertyInfo class, System.Reflection override keyword, 163–64 namespace, 396 overview, 162 protected access modifier, 77 virtual keyword, 163–64 protected internal access modifier, 77 portType element, WSDL document elements, protected keyword, 158 938–39 provider factory model, ADO.NET, 770–72 Position, Stream class, System.IO, 532 proxies and messages, remoting, 567–68 POST data type, 940 proxy code using Visual Studio 2005, XML web PreInit, ASP.NET Page events, 862 services, 947–48 preprocessor directives, 289, 316–19 Proxy( ) method, SoapHttpClientProtocol class, PreRender, ASP.NET Page events, 862 945 974 ■INDEX

public access modifier, 77 RegisteredChannels property, remoting publisher policy assemblies, 384–85 ChannelServices, 579 push and pop, 480, CIL RegisterWellKnownClientType( ) method, RemotingConfiguration, 580 ■Q RegisterWellKnownServiceType( ) method, Query Analyzer, SQL Server, 775 RemotingConfiguration, 580 Queue System.Collections class type, 250–52 registration of events, 279–81 RegularExpressionValidator control, ASP.NET, ■R 884, 886 RadioButton control, 711, 713 RejectChanges( ) method, ADO.NET DataSet RangeValidator control, ASP.NET, 884, 886 class, 795 reachable objects, 180 remoting Read( ) method alternative hosts, 597 BinaryReader class, 538 assemblies required, 574–75 Stream class, System.IO, 532 asynchronous invocation, 602–3 TextReader, System.IO, 535 automatic server-side loading, 597 ReadBlock( ) method, TextReader, System.IO, 535 CAO activation, 572–73 ReadByte( ) method, Stream class, System.IO, channels, 568–69 532 ChannelServices, 579 reading client-activated, 590–91 cookies, ASP.NET, 911–12 client-side configuration files, 585–86 resources, 697 configuration files, 584 from a text file, 535 default layers, 570 ReadLine( ) method, TextReader, System.IO, 535 definition, 565 read-only class properties, 153–54 deploying remote server, 582 readonly keyword, 82–83 deployment, 574–75 ReadOnly property determining MBR runtime information, ADO.NET DataColumn object, 797 580–81 UpDownBase, 728 dispatcher, 569 ReadToEnd( ) method, TextReader, System.IO, example application, 575–78 535 formatters, 569 ReadXml( ) method, ADO.NET DataSet class, garbage collection, 592–97 795 hosting using IIS, 601–2 ReadXmlSchema( ) method, ADO.NET DataSet HTTP channel, 568 class, 795 IIS hosting, 597 ready state, Menu selection in Visual Studio installing a Windows service, 600–601 2005, 639 IPC channel, 568, 583 real proxy, remoting, 568 lease configuration, 594–96 Rectangle(F) type, System.Drawing namespace, lease sponsorship, 596 652–53 lease-based lifetimes, 592–97 Redirect( ) method, ASP.NET HTTP Response, marshaling, 570 860 MBV objects, 586–89 redirecting users, ASP.NET, 861 namespaces, 566–67 ref method parameter modifier, 89–91 .NET Framework architecture, 567 reference types, 96–100, 103–4 one-way invocation, 604 references overview, 565 differences from classes and objects, 179 proxies and messages, 567–68 memory management using, 180–81 real proxy, 568 new keyword, 180 server-side configuration files, 584–85 reflection, 395 singleton WKO activation, 573 Region class, System.Drawing namespace, 653 singleton WKO and multiple clients, Register( ) method, ILease interface remoting, 581–82 593 TCP channel, 568, 582–83 RegisterActivatedClientType( ) method, transparent proxy, 567 RemotingConfiguration, 580 Windows service construction, 597, 599 RegisterChannel( ) method, remoting WKO activation, 572–73 ChannelServices, 579 WKO and CAO configuration summary, 574 registered data provider factories, ADO.NET, RemotingConfiguration, 580 771–72 RemotingFormat property, ADO.NET DataSet class, 795 ■INDEX 975

Remove( ) method separation of concerns, objects, 72 ASP.NET, 908 Serializable attribute, 409 ASP.NET HttpApplicationState members, 898 serialization ControlCollection, 702 BinaryFormatter object graph contents, 557 System.MulticastDelegate/System Delegate, collections, 555–56 263 customizing using attributes, 560–61 RemoveAll( ) method customizing using ISerializable, 558–60 ASP.NET, 908 definition, 545 ASP.NET HttpApplicationState members, 898 GetObjectData( ) method, 558–60 System.MulticastDelegate/System Delegate, IFormatter interface, 549 263 ISerializable interface, 557 RemoveAt( ) method object graph, 546 ASP.NET HttpApplicationState members, 898 ObjectIDGenerator, 557 ControlCollection, 702 OnDeserializedAttribute, 557 removing controls, ASP.NET, 869–70 OnDeserializingAttribute, 557 Renew( ) method, ILease interface remoting, OnSerializedAttribute, 557 593 OnSerializingAttribute, 557 RenewOnCallTime, ILease interface remoting, OptionalField attribute, 561–63 593 OptionalFieldAttribute, 557 Request, ASP.NET HttpApplication members, overview, 545 897 persisting user preferences example, Request, Page Type properties, ASP.NET, 856 545–46 request/response cycle, HTTP, 829 public and private fields, public properties, RequiredFieldValidator control, ASP.NET, 548 884–85 Serializable attribute, 547–48 resource writers in .NET, 694 SerializationInfo, 557 ResourceResolve event, System.AppDomain, 436 System.Runtime.Serialization.Formatters.Bin resources in .NET, 691–93 ary namespace, 548 resources using Visual Studio 2005, 694–95, 697 type fidelity, 550 Responding, System.Diagnostics.Process, 429 versioning, 561–63 Response SerializationInfo, serialization, 557 ASP.NET HttpApplication members, 897 Serialized attribute, 409 Page Type properties, ASP.NET, 856 Server Resume( ) method, Thread type, 460 ASP.NET HttpApplication members, 897 .resx files, 691–93 Page Type properties, ASP.NET, 857 ResXResourceWriter, 694 server controls in ASP.NET, 865–66 return value, interface used as, 228 Server property, WebService base class, 929 role of XML web services, 919–20 server-side configuration files, remoting, root, application, 182 584–85 Root property, DirectoryInfo class, 520 service element, WSDL document elements, round-trip engineering, 481–85 939–40 RowState, ADO.NET DataRow object, 798 Session, ASP.NET HttpApplication members, RPC protocol, 940 897 runat attribute, ASP.NET, 847 session cookies, ASP.NET, 909–10 runtimes, MFC, VB 6, Java and .NET, 20 session data, ASP.NET, 906–8 Session, Page Type properties, ASP.NET, 857 ■S Session property, WebService base class, 929 SaveAs( ) method, ASP.NET HTTP Request, 858 session state and web.config, XML web services, saving CIL code using ildasm.exe, 481–83 935 script block, ASP.NET, 847 Session_End( ), Global.asax event handlers in ScrollBars property, Textbox, 705 ASP.NET, 896 sealed classes, 159, 164 Session_Start( ), Global.asax event handlers in Seek( ) method ASP.NET, 896 BinaryWriter class, 538 SessionID, ASP.NET, 908 Stream class, System.IO, 532 sessionState element, Web.config, ASP.NET, 913, SelectedIndex property, DomainUpDown, 728 915–16 SelectedItem property, DomainUpDown, 728 SetLength( ) method, Stream class, System.IO, Semaphore type, System.Threading 532 Namespace, 459 shallow copy, cloneable objects (ICloneable), 238–41 976 ■INDEX

SharpDevelop IDE state management, 889–91 Assembly Scouts, 48 State property, DbConnection, ADO.NET, 779 compiling common intermediate language stateful data, XML web services, 933, 935 (CIL), 486 stateless, description, HTTP, 830 download link, 46 static assemblies, 504 features, 47 static class properties, 154–55 installing or compiling, 46 static keyword, 83–88 overview, 46 static readonly keywords, 83 Project and Classes Scouts, 47 static web service discovery using DISCO, 921 Windows Forms Designers, 49–50 StatusBar vs. StatusStrip, 633 shopping cart application, ASP.NET, 906–8 StatusStrip, Visual Studio 2005, 633–34, 636–37 single call WKO activation, remoting, 573 stored procedures using DbCommand, single file code model, ASP.NET, 842–43 ADO.NET, 790–91 single-file assemblies, 11 Stream class, System.IO, 531–32 singleton WKO activation, remoting, 573 StreamReader, StreamWriter sink object, callback interfaces, 256–57, 259 direct creation, 536 Size property, ADO.NET DbParameter, 789 System.IO, 533 sizeof keyword, 316 StreamWriter, StreamReader types, SkinID property, System.Web.UI.Control in input/output, System.IO, 518 ASP.NET, 867 StringCollection, Sleep( ) method, Thread type, 460 System.Collections.Specialized, 253 SmallChange property, TrackBar control, 724 String.Concat( ) method, 124 Smalltalk .NET programming language, 8 StringDictionary, sn.exe, strong name utility, 371, 373, 375–76 System.Collections.Specialized, 253 SOAP bindings, 941–42 StringEnumerator, SOAP transport of web service, 922 System.Collections.Specialized, 253 SoapFormatter, serialization, 548, 552 String.Format( ) method, 76 SoapHttpClientProtocol class, 944–45 StringReader, StringWriter, System.IO, 536–37 SoapVersion property, WebService base class, strings 929 comparing, 124 software development, 3–5 internal .NET string processing, 126 sort order of tables, ADO.NET, 807–8 iterating over, 124 Sorted property, DomainUpDown, 728 StringWriter, StringReader types, input/output, SortedList System.Collections class type, 250 System.IO, 518 sorting and paging example, ASP.NET, 878–79 strong names in assemblies, 348, 357, 371, spawning child forms in MDI applications, 373–74 647–48 structures SponsorshipTimeout, ILease interface common intermediate language (CIL), 491 remoting, 593 and enumerations, value based types, 97 SQL command autogenerating, ADO.NET, types, 16 816–17 in XML web services, 949–50 SQL for Fill( ) and Update( ), ADO.NET, data submitting form data, ASP.NET, 837–38 adapter, 811 subsystem directive, common intermediate stack, and value based types, 96 language (CIL), 489 Stack System.Collections class type, 250, 252–53 Suspend() method, Thread type, 460 stackalloc keyword, 314–15 switch statement, 95–96 stack-based programming, 480, CIL Synchronization attribute StackTrace property, System.Exception, 200, 205 context bound objects, 442 standard dialogs, System.Windows.Forms, 606 multithreaded applications, 472–73 Start( ) method synchronizing threads, 455–56 System.Diagnostics.Process, 429 synchronous delegate call, 260 Thread type, 460 System data types, 117–18 StartAddress, ProcessThread type, 432 System.Activator class, late binding, 406–7 starting and stopping a process example code, System.AppDomain class 434–35 AssemblyLoad event, 436 StartTime AssemblyResolve event, 436 ProcessThread type, 432 BaseDirectory( ), 436 System.Diagnostics.Process, 429 CreateDomain( ), 435, 437 StartupPath property, Application class, 609 CreateInstance( ), 436 state data, multithreaded applications, 458 DomainUnload event, 436 ■INDEX 977

ExecuteAssembly( ), 436 System.Drawing.Brush, 677 GetAssemblies( ), 436 System.Drawing.Drawing2D GetCurrentThreadId( ), 435 core classes, 672 Load( ), 436, 438 GDI+ namespaces, 650 ProcessExit event, 436 Pen types, 673–74 ResourceResolve event, 436 Pens, LineCap, 675–76 TypeResolve event, 436 System.Drawing.Font, GDI+, 665 UnhandledException event, 436 System.Drawing.Graphics class Unload( ), 436, 439–40 methods, 653 System.ApplicationException, structured Paint sessions, 655–56 exception handling, 208–10 properties, 654 System.Array, 130 System.Drawing.Image, 682, 684 System.Boolean, 120 System.Drawing.Imaging, GDI+ namespaces, System.Char, 121 650 SystemCLSCompliant( ), CLS compliance System.Drawing.Printing, GDI+ namespaces, verification, 20 650 System.Collection.ArrayList, indexer technique, System.Drawing.Text, GDI+ namespaces, 650 290–91 System.Enum, 109–10 System.Collections class types, 249 System.Environment class, 68–69 ArrayList, 250–51 System.EventHandler, Application Exit, 611 Hashtable, 250 System.Exception Queue, 250–52 Data property, 200, 206–7 SortedList, 250 HelpLink property, 200, 206 Stack, 250, 252–53 InnerException property, 200 System.Collections interfaces, 247–49 Message property, 200, 210 System.Collections.Generic class overview, 321 StackTrace property, 200, 205 System.Collections.Generic.List<> TargetSite property, 200, 204 CIL code, 326 System.GC, 185–87 classes, 327 System.Guid, 240–42 generics, 325 System.MarshalByRefObject naming convention, 327 CreateObjRef( ), 572 nongeneric namespaces, 327 Form object inheritance chain, 612 nongeneric namespaces mimiced, 326 GetLifetimeServices( ), 572 System.Collections.Specialized, 253 InitializeLifetimeServices( ), 572 System.Collections.Specialized.ListDictionary, System.MulticastDelegate base class, 262 indexer technique, 291–92 System.MulticastDelegate/System Delegate System.ComponentModel, 746 members, 263 System.ComponentModel.Component, Form System.Nullable, 132 object inheritance chain, 612 System.Object, 111 System.Configuration namespace, 387 default behavior, 112–13 System.Console class, 73–75 Equals( ), 117 basic I/O, 73 Equals( ), operator overloading, 296–97 formatting output, 74–75 Form object inheritance chain, 612 System.ContextBoundObject, 441 GetType( ) method, 397 System.Data, ADO.NET, 764–65 instance-level members, 111 Contraint, 764 overriding default behavior, 113 DataColumn, 764 overriding Equals( ), 114–15 DataRelation, 764 overriding GetHashCode( ), 115–16 DataRow, 764 overriding members example, 116 System.DateTime, 122 overriding ToString( ), 114 System.Delegate base class, 262 ReferenceEquals( ), 117 System.Diagnostics namespace, 428 static members, 117 System.Diagnostics.Process, 428–29 vs. System.ValueType, 97 System.Drawing, GDI+ namespaces, 650 System.OverflowException, 307–9 System.Drawing namespace System.Reflection, 396 core types, 650–51 System.Reflection.Emit namespace Point(F) type, 651–52 creating dynamic CIL assemblies, 505 Rectangle(F) type, 652–53 overview, 477 Region class, 653 System.Reflection.Emit.ILGenerator, 506 utility types, 651 System.Resources namespace, 691 978 ■INDEX

System.Runtime.Remoting, remoting System.Web.Profile namespace, ASP.NET 2.0, namespace, 566 842 System.Runtime.Remoting.Activation, remoting System.Web.Security namespace, ASP.NET 2.0, namespace, 566 842 System.Runtime.Remoting.Channels, remoting System.Web.Services.Configuration, XML web namespace, 566 services namespaces, 922 System.Runtime.Remoting.Channels.Http, System.Web.Services.Description, XML web remoting namespace, 566 services namespaces, 922 System.Runtime.Remoting.Channels.Ipc, System.Web.Services.Discover, XML web remoting namespace, 566 services namespaces, 922 System.Runtime.Remoting.Channels.Tcp, System.Web.Services.Protocols, XML web remoting namespace, 566 services namespaces, 922 System.Runtime.Remoting.Contexts, remoting System.Web.ServicesXML web services namespace, 566 namespaces, 922 System.Runtime.Remoting.Lifetime, remoting System.Web.SessionState namespace, ASP.NET namespace, 566 2.0, 842 System.Runtime.Remoting.Messaging, System.Web.UI.Control in ASP.NET, 867 remoting namespace, 566 System.Web.UI.Page, ASP.NET, 856 System.Runtime.Remoting.Metadata, remoting System.Web.UI.x namespace, ASP.NET 2.0, 842 namespace, 566 System.Windows.Forms, 605–6, 699 System.Runtime.Remoting.MetadataServices, System.Windows.Forms.ContainerControl, remoting namespace, 566 Form object inheritance chain, 612 System.Runtime.Remoting.Metadata. System.Windows.Forms.Control W3cXsd2001, remoting namespace, core properties, 612–13 566 events, 613 System.Runtime.Remoting.Proxies, remoting Form object inheritance chain, 612 namespace, 567 methods, 613–14 System.Runtime.Remoting.Services, remoting System.Windows.Forms.Form, Form object namespace, 567 inheritance chain, 612 System.Serializable attribute, structured System.Windows.Forms.ScrollableControl, exception handling, 211 Form object inheritance chain, 612 System.String data type, 123 System.SystemException, structured exception ■T handling, 208 tab order for controls, 718 System.Text.StringBuilder, 126–27 TabControl control, 722–23 System.Threading Namespace Table, ADO.NET DataRow object, 798 Interlocked type, 459 Table property, ADO.NET DataColumn object, Monitor type, 459 797 Mutex type, 459 TableLayoutPanel, controls, 756–57 ParameterizedThreadStart delegate, 459, Target property, 462–63, 465–66 System.MulticastDelegate/System Semaphore type, 459 Delegate, 263 Thread type, 459–60 TargetSite property, System.Exception, 200, 204 ThreadPool type, 459, 475–76 TCP channel, remoting, 568, 582–83 ThreadPriority enum, 459 template, exception code expansion, 211 ThreadStart delegate, 459, 463–64 text based Windows.Forms coding, 606 ThreadState enum, 459 Text property, UpDownBase, 728 Timer type, 459 TextAlign property TimerCallback delegate, 459, 473–74 Button, 709 System.TimeSpan, 122 Textbox, 705 System.Type class, 396–97 UpDownBase, 728 System.ValueType, 97 TextBox control, 705–7 System.ValueType, struct default base, 222 TextPad development editor, 41 System.Web namespace, ASP.NET 2.0, 842 C Shart Helpers clip library, 45 System.Web.Caching namespace, ASP.NET 2.0, configuring for C#, 42–43 842 executing programs, 44 System.Web.Hosting namespace, ASP.NET 2.0, predefined run commands, 44–45 842 TextReader, System.IO, 535 System.Web.Management namespace, ASP.NET TextureBrush, System.Drawing.Brush, 679–80 2.0, 842 ■INDEX 979

TextWriter, System.IO, 534 transforming XML documentation to HTML, Theme, Page Type properties, ASP.NET, 857 177 this keyword, 142–43 transparent proxy, remoting, 567 this[ ] syntax, indexer technique, 290–91 TreeView controls, 731–36 ThousandsSeparator property, type constructors, common intermediate NumericUpDown, 728 language (CIL), 494 Thread type, 449, 459–62 type reflection ThreadExit event, Application class, 609 AssemblyRef, 394 Thread.GetDomain( ), 449 description, 395 ThreadPool type, System.Threading example metadata, 393–94 Namespace, 459, 475–76 external private assemblies, 402–3 ThreadPriority enum, System.Threading fields and properties, 398 Namespace, 459 implemented interfaces, 399 threads metadata and type reflection, 391–92 example code, 430–31 method parameters and return values, 401–2 hyperthreading, 427 methods, 398 multithreading, 426 other metadata, 399 overview, 426 overview, 391 suspended during garbage collection, 182 shared assemblies, 404–6 Thread Local Storage (TLS), 427 TypeDef, 392 time slice, 427 TypeRef, 392 Threads, System.Diagnostics.Process, 429 User Strings, 395 ThreadStart delegate, System.Threading TypeBuilder, System.Reflection.Emit Namespace, 459, 463–64 namespace, 505 ThreadState enum, System.Threading typed exceptions, structured exception Namespace, 459 handling, 217 ThreadState method, Thread type, 460 TypeDef, 392 ThreeState property, Button, 711 typeof operator, 398 ThrowException( ) method, TypeRef, 392 System.Reflection.Emit.ILGenerator, TypeResolve event, System.AppDomain, 436 506 types TickFrequency property, TrackBar control, 724 access modifiers, 78 TickStyle property, TrackBar control, 724 definition, 15 time slice, 427 determining, 172 Timeout( ) method, SoapHttpClientProtocol five categories of, 15–17 class, 945 parameters, 321 Timer type, System.Threading Namespace, 459 visibility, 78 Timer, Visual Studio 2005, 637–38 types element, WSDL document elements, 937 TimerCallback delegate, System.Threading Namespace, 459, 473–74 ■U tokens UDDI discovery of XML web services, 953–54 formatting output, 74–75 UDDI web service discovery, 921 in MaskedTextBox control, 707 unbound type parameters, 335–36 ToolBar components in ToolStrips, 639–41 unboxing. See boxing and unboxing ToolStripMenuItem types, Visual Studio 2005, unchecked keyword, 309 632–33 unhandled exceptions, structured exception ToolStrips in Visual Studio 2005, 639–41 handling, 217 ToolTip control, 721–22 UnhandledException event, ToString( ), System.Object instance-level System.AppDomain, 436 member, 112 Unique property, ADO.NET DataColumn TotalProcessorTime, ProcessThread type, 432 object, 797 Trace, ASP.NET <%@Page%> directive attribute, unit of measure, GDI+, 660 846 Unload( ), System.AppDomain, 436 trace element attributes, Web.config, ASP.NET, Unload, ASP.NET Page events, 862 913 Unlock( ) method, ASP.NET trace element, Web.config, ASP.NET, 913–14 HttpApplicationState member, 898 Trace, Page Type properties, ASP.NET, 857 unmanaged resources, 185, 189–95 TrackBar control, 724–26 Unregister( ) method, ILease interface Transaction object, ADO.NET data providers, remoting, 593 761 980 ■INDEX

UnregisterChannel( ) method, remoting Visual C# 2005 Express, 51 ChannelServices, 579 Visual Studio 2005 unsafe compiler flag, 310 additions available, 52 unsafe keyword, 311–12 automated coding support, 57 Update( ) method, ADO.NET, data adapter, 811 Class View, 53 UpdateCommand property in updating, Code Definition window, 54 ADO.NET, 815 code refactoring support, 55 updating ContextMenuStrip controls, 626, 630–32 applications using shared assemblies, 378–79 deprecated controls, 623 records, ADO.NET, 787 designer.cs form file, 624 rows, ADO.NET, 809 event handling in ToolStrips, 643 using data adapter objects, ADO.NET, 813–15 event registration, 280–81 UpDown control, 727, 729 form files in a project, 623 UpDownAlign property, UpDownBase, 728 forms designer, 621 UpDownBase, 728 FxCop, 62 Url( ) method, SoapHttpClientProtocol class, generating resources, 694–95, 697 945 handling events, 625 user errors, 197 images in ToolStrips, 641–43 user interface in HTML, 834–35 integrated Help system, 60–61 UserAgent( ) method, SoapHttpClientProtocol interface implementation, 234–35 class, 945 Lutz Roeder’s Reflector for .NET, 62 UserControl Test Container, 743 MDI applications, 646 user-defined type (UDT), definition, 69–70 menu items in controls, 632 using keyword, 136–37, 192–93 Menu selection prompts, 639 UsingNamespace( ) method, Menu selection ready state, 639 System.Reflection.Emit.ILGenerator, menu systems, 634, 636–37 506 MenuStrip controls, 626–28, 630 NAnt, 62 ■V NDoc, 62 Validated, control class property, 730 .NET 1.x controls, 623 ValidateInput( ) method, ASP.NET HTTP Nunit, 62 Request, 858 Object Browser, 54 Validating, control class property, 730 Object Test Bench, 60 validating form data, ASP.NET, 837 overview, 51, 621 validation controls, ASP.NET, 884–87 Program class, 625 ValidationSummary control, ASP.NET, 884, 887 project configuration (Project Properties), 53 value and reference types, conversion, 104–6 project templates, 621 value, contentual keyword, 151 properties window, 622 Value property refactoring example, 56 ADO.NET DbParameter, 789 refactoring techniques available, 55 NumericUpDown, 728 Snippets automated coding, 57 TrackBar control, 724 Solution Explorer, 52 value types, 96–100, 103–4 StatusStrip, 633–34, 636–37 variables, local, common intermediate Surround With automated coding, 57 language (CIL), 498 Timer, 637–38 VB6 language deficiencies, 4 Toolbox, 621 VB.NET operator overloading, 300 ToolStrip containers, 643, 645 verbatim strings, 125 ToolStripMenuItem types, 632–33 version number of assemblies, 348 ToolStrips, 639–41 view objects, ADO.NET, 810 Vil, 62 view state, state management in ASP.NET, 891–93 Visual Class Designer, 57–59 Vil development tool, 62 virtual execution stack, 480, CIL ■W virtual keyword, description, 163–64 WaitReason, ProcessThread type, 432 Visible property, System.Web.UI.Control in Web Application Administration utility, ASP.NET, 867 ASP.NET, 916–17 Visual Basic .NET integration with C#, 360, 362, web applications in ASP.NET 364–65 application cache, 901 Visual Basic snap-in example, 420–21 application level state data, 898–99 ■INDEX 981

application shutdown, 900 Win 32 binaries (*.dll or *.exe), 10 applications vs. sessions, 897 Win32 file header in assemblies, 349 configuration inheritance, 917–18 Windows Distributed interNet Applications control state, state management, 894 Architecture (DNA) deficiencies, 5 cookies creation, 909–10 Windows forms controls, 699 custom view states, state management, Windows forms snap-in example, 421–22 893–94 Windows objects and Graphics objects, GDI+, data caching, 901, 903–5 657 Global.asax file, 894–96 Windows service installation, 600–601 HttpApplication type overview, 889 Windows XP Home Edition and ASP.NET, 832 HttpSessionState members, 908 Windows.Forms coding maintaining session data, 906–8 += operator, 610 modifying application data, 899–900 Application class, 609 overview, 889 ApplicationExit event, 609–10 per user data stores, 906–8 coding the main window, 607–8 persistence of cookies, 909–10 Form class, 607 problems in state management, 889–91 Form object inheritance chain, 611 reading cookies, 911–12 keyboard input, 614, 617 session cookies, 909–10 mouse events, 615–17 session data, 906–8 overview, 606 site administration utility, 916–17 reflecting static attributes, 609 state management overview, 889 responding to events, 614–17 state management techniques, 891 separating Main( ) method from main view state, state management, 891–93 window, 608 Web Application Administration utility, System.EventHandler, 611 916–17 winexe compile target, 607 Web.config, 912–16 wizards, ADO.NET, 822–25 web controls in ASP.NET, 865–66 WKO activation, remoting, 572–73 web page code model, ASP.NET, 842–46 worker thread, 426 Web Server, .NET platform SDK, 924 world coordinates, GDI+ coordinate systems, 659 web service client architecture, 920 Wrap property, DomainUpDown, 728 Web.config, ASP.NET Write( ) method appSetting element, 912 ASP.NET HTTP Response, 860 authentication element, 912 BinaryWriter class, 538 authorization element, 912 Stream class, System.IO, 532 compilation element, 913 TextWriter, System.IO, 534 connectionStrings element, 913 WriteByte( ) method, Stream class, System.IO, customErrors element, 913–15 532 globalization element, 913 WriteFile( ) method, ASP.NET HTTP Response, sessionState element, 913, 915–16 860 trace element, 913–14 WriteLine( ) method, TextWriter, System.IO, 534 WebControl base class properties, ASP.NET, write-only class properties, 153–54 870–71 WriteXml( ) method, ADO.NET DataSet class, WebControl controls, 736–37 795 WebDev.WebServer.exe, 832 WriteXmlSchema( ) method, ADO.NET DataSet WebMethod attribute, 409 class, 795 WebMethod attribute, XML web services, writing to a text file, 534–35 932–33, 935 WSDL (Web Service Description Language), WebMethodAttribute, XML 921, 925, 935 System.Web.Services namespace, 923 document elements WebService base class, 929 binding element, 939 WebService base class, XML message element, 938 System.Web.Services namespace, 923 portType element, 938–39 WebServiceAttribute, XML System.Web.Services service element, 939–40 namespace, 923, 929–30 types element, 937 WebServiceBindingAttribute, XML XML web services, 936–39, 940 System.Web.Services namespace, 923 name clashes, XML web services, 933 website directory structure, ASP.NET, 851 wsdl.exe utility, XML web services where keyword, generics, 337 /appsettingurlkey flag, 942 while, do/while loops, 93 creating a client-side proxy, 944 982 ■INDEX

generating server-side code, 943 HTTP transport, 922 /language flag, 942, 944 HTTP use, 919–20 /namespace flag, 942 IIS deployment, 925 /out flag, 943 machine.config file, 940 /protocol flag, 943–44 manual web service coding, 923 /serverInterface flag, 943 Name property, 930 WSI basic profile (BP 1.1) conformance, XML Namespace property, 930 web services, 932 namespaces, 922 WsiProfiles enumeration, XML overview, 919 System.Web.Services namespace, 923 vs. proprietary wire protocols, 919–20 proxy code using Visual Studio 2005, 947–48 ■X role, 919–20 Xcopy deployment, 365 session state and web.config, 935 XML SOAP body, 941 and ADO.NET, 759 SOAP envelope, 941–42 code comment format characters, 177 SOAP transport, 922 /doc compiler flag, 177 stateful data, 933, 935 documentation elements, 175 static web service discovery using DISCO, source code documentation, 175–77 921 transforming to HTML, 177 structures using web methods, 949–50 XML System.Web.Services namespace, 923 synchronous invocation, wsdl.exe utility, 946 XML web services. See also WSDL (Web Service System.Web.Services namespace, 922 Description Language) transport protocal, description, 921 <%@WebService%> directive, 923 UDDI and Visual Studio .NET, 954 ADO.NET datasets using web methods, 950 UDDI discovery, 921, 953–54 arrays using web methods, 949 using Visual Studio.NET, 926–28 asynchronous invocation, wsdl.exe utility, viewing SOAP messages, 942 946–47 Web Service Description Language (WSDL), autogenerated test page, 925 935 benefits, 919–20 web.config and session state, 935 client architecture, 920 web.config file, 941 client-side representation, 952–53 WebDev.WebServer.exe, 924 custom test page, 925–26 WebMethod attribute, 923, 932 custom types using web methods, 948 WebService base class, 929 default constructor, wsdl.exe utility, 945 WebServiceAttribute, 929–30 DefaultWsdlHelpGenerator.aspx, 925–26 WebServiceBinding attribute, 931 Description property, 930 Windows Forms clients, 951–52 description service, description, 921 wire protocols, 940 DISCO UDDI directory, 921 wsdl.exe utility, 942–47 discovery service, description, 921 WSI basic profile (BP 1.1) conformance, 932 dynamic web service discovery using DISCO, XmlAttributeAttribute, XmlSerializer, 554 921 XmlElementAttribute, XmlSerializer, 554 example application, wsdl.exe utility, 947 XmlEnumAttribute, XmlSerializer, 554 example web service, 928–29 XmlRootAttribute, XmlSerializer, 554 HTTP GET, 940 XmlSerializer, 548–49, 553–55 HTTP POST, 940 XmlTextAttribute, XmlSerializer, 554 HTTP SOAP, 940