Introducing Microsoft .NET (Pro-Developer)
Chapter 2: .NET Objects
- Listing 2-1: Visual Basic code listing of simplest object server.
- Listing 2-2: C# code listing of simplest object client.
- Listing 2-3: AssemblyInfo.vb file entry specifying key pair for generating strong name.
- Listing 2-4: AssemblyInfo.vb file showing version of component assembly.
- Listing 2-5: Sample configuration file.
- Listing 2-6: Explicit declaration of inheritance.
- Listing 2-7: Overriding base class method.
- Listing 2-8: Constructor declaration example.
- Listing 2-9: Constructor call example.
- Listing 2-10: Providing a Finalize function in an object.
- Listing 2-11: Sample Dispose method for deterministic finalization.
- Listing 2-12: Code listing of a .NET client using an RCW.
- Listing 2-13: Sample late binding code.
- Listing 2-14: COM+ transactions in a native .NET object.
- Listing 2-15: Client application code showing structured exception handling.
- Listing 2-16: Throwing an exception in SEH.
- Listing 2-17: Finally handler in structured error handling.
Chapter 3: ASP.NET
- Listing 3-1: Intermingling of code and HTML in ASP.
- Listing 3-2: Excerpts from the code behind the WebForm1.aspx page.
- Listing 3-3: Excerpts from .ASPX page created by Visual Studio .NET, showing control statements.
- Listing 3-4: Excerpts from the HTML generated by the controls.
- Listing 3-5: Excerpts from the sample application’s web.config file.
- Listing 3-6: Code for session state management.
- Listing 3-7: Session state management entries in the web.config file.
- Listing 3-8: Web.config file for forms-based authentication.
- Listing 3-9: Code for forms-based authentication form.
- Listing 3-10: Authorization entries in a web.config file.
- Listing 3-11: Web.config file showing authorization entries for domain users using Windows authentication.
- Listing 3-12: Global.asax.vb code to set role membership on a user’s page request.
- Listing 3-13: Code to place role membership in authentication cookie for later use.
- Listing 3-14: Code to discover the role a user belongs to.
- Listing 3-15: Web.config file specifying server process identity.
- Listing 3-16: Web.config setting for automatic impersonation.
- Listing 3-17: Machine.config file showing process recycling settings.
Chapter 4: .NET Web Services
- Listing 4-1: A basic XML Web service.
- Listing 4-2: An excerpt from a WSDL file.
- Listing 4-3: SOAP request packet.
- Listing 4-4: SOAP response packet.
- Listing 4-5: Code accessing XML Web service by means of a proxy.
- Listing 4-6: Proxy code generated by Visual Studio.
- Listing 4-7: Turning on session state using the WebMethod attribute.
- Listing 4-8: SOAP <Fault> example.
- Listing 4-9: Placing a namespace on your XML Web service.
- Listing 4-10: SOAP packet containing authentication information for Web Services Enhancements
- Listing 4-11: Client-side code
- Listing 4-12: WSE Sample Web.config file
- Listing 4-13: Implementation of IPasswordProvider.
Chapter 5: Windows Forms
- Listing 5-1: Simplest sample app’s code listing.
- Listing 5-2: Excerpted version of the InitializeComponent method showing control creation.
- Listing 5-3: Event handler for a button click.
- Listing 5-4: Windows Forms ActiveX sample code.
- Listing 5-5: Overridden OnPaint method of a form.
- Listing 5-6: OnMouseDown overridden method to process mouse clicks.
- Listing 5-7: Code modifying context menu before form automatically shows it.
- Listing 5-8: Code handling OnKeyDown notification.
- Listing 5-9: Code that displays a dialog box to the user and reports its results.
Chapter 6: Data Access in .NET
- Listing 6-1: The Page_Load event handler of the simplest ADO.NET sample.
- Listing 6-2: The GetAuthors method.
- Listing 6-3: Code from the application.
- Listing 6-4: Code from my own class MyOwnListItem.
- Listing 6-5: Code allowing editing of author info.
- Listing 6-6: Updating author information.
- Listing 6-7: XML Web service sample code for getting and updating author information.
- Listing 6-8: Client code for typed XML Web service sample.
Chapter 7: Handling XML
- Listing 7-1: Code used to access an XML element in a generic parser.
- Listing 7-2: Point class for simplest serialization example.
- Listing 7-3: Code for serializing a point.
- Listing 7-4: XML document produced by serialization.
- Listing 7-5: Deserializing the XML document into a .NET object.
- Listing 7-6: Point class that serializes to attributes.
- Listing 7-7: XML representation of serialized class in attributes.
- Listing 7-8: Rectangle class that can hold either element points or attribute points.
- Listing 7-9: XML document produced by serializing rectangle.
- Listing 7-10: Schema of Point class from first example produced by XSD.exe.
- Listing 7-11: Industry-standard XML document describing polygon.
- Listing 7-12: Polygon XML document wrapper class produced by XSD.exe.
- Listing 7-13: Enumeration code using DOM parser.
Chapter 8: Events and Delegates
- Listing 8-1: Visual Basic code for the simplest event component.
- Listing 8-2: C# code for simplest event.
- Listing 8-3: Visual Basic .NET code for handling events.
- Listing 8-4: C# event handler code added by the wizard.
- Listing 8-5: Visual Basic code for adding and removing an event handler.
- Listing 8-6: C# code for adding and removing an event handler.
- Listing 8-7: Adding a handler for various events.
- Listing 8-8: Declaring and creating the delegate for asynchronous operation.
- Listing 8-9: Functions for an asynchronous call with a polled completion signal.
- Listing 8-10: A handler function for an asynchronous method invocation with a callback completion signal.
Chapter 9: Threads
- Listing 9-1: Simplest threading sample application code that queues a work item.
- Listing 9-2: Simplest threading application target function that does the work.
- Listing 9-3: Assembler code produced by compiling that source code.
- Listing 9-4: Attribute-synchronized component.
- Listing 9-5: Individual method using SyncLock for synchronization in Visual Basic.
- Listing 9-6: Same functionality in C#.
- Listing 9-7: Code providing orderly shutdown of multithreaded app.
Chapter 10: .NET Remoting
- Listing 10-1: Host channel registration code.
- Listing 10-2: Client-side registration code.
- Listing 10-3: Client-side object creation and method call.
- Listing 10-4: Server-side configuration file.
- Listing 10-5: Client-side configuration file.
- Listing 10-6: Client-side code using a configuration file.
- Listing 10-7: Code for creating a published object.
- Listing 10-8: Lifetime lease management overriding in a configuration file.
- Listing 10-9: Setting up a lease sponsor.
- Listing 10-10: Sample lease sponsor.
- Listing 10-11: Web.config file for IIS hosting.
- Listing 10-12: Client config file entries.
- Listing 10-13: Authentication code for IIS hosting.
Chapter 11: .NET Reflection
- Listing 11-1: Code that reads metadata properties of an assembly
- Listing 11-2: Code that obtains the list of types and puts each in the tree control
- Listing 11-3: Class marked with a custom attribute
- Listing 11-4: Code for creating method parameter entry controls
- Listing 11-5: Code for creating an object and invoking its method dynamically