You are previewing Microsoft® Visual J#™ .NET (Core Reference).
O'Reilly logo
Microsoft® Visual J#™ .NET (Core Reference)

Book Description

Java-language developers—learn how to create .NET applications with the Microsoft development tool for you: Visual J# .NET.

Leverage your Java skills and learn how to create powerful Microsoft Windows® applications and high-performance, distributed applications with Visual J# .NET in this comprehensive tutorial and reference. Presented in an easy-to-browse format, this erudite book gives you the authoritative technical details you need to leverage Microsoft Visual J# .NET and the richness of the Microsoft .NET Framework to create scalable, enterprise-level applications. You'll examine the architecture of .NET, find out how to process data with Visual J# .NET, see how to create XML Web services, and discover how to build multithreaded applications that span the local area network. You'll also look at the key topics for building applications that use Windows features and services and find out how to provide a global reach to your applications via the Internet.

Table of Contents

  1. Microsoft Visual J# .NET
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. Acknowledgments
    3. Introduction
      1. How This Book Is Organized
      2. System Requirements
      3. Installing the Sample Files
        1. Microsoft Press Support Information
    4. I. The Architecture of .NET
      1. 1. The Challenge of N-Tier Development
        1. Client/Server and N-Tier Architectures
          1. Two-Tier Architecture
          2. N-Tier Architecture
          3. The Northwind Traders Example
            1. Application Requirements
            2. Design Patterns
        2. Connectivity and Data Formats
          1. Sockets
          2. Remote Procedure Calls
          3. Object RPCs
            1. CORBA
            2. Distributed COM
          4. Remote Method Invocation
            1. Serialization
            2. Reference and Value Objects
          5. The Web
            1. HTTP
            2. Web Services
            3. SOAP
        3. Data Access
          1. Open Database Connectivity
          2. Java Database Connectivity
          3. ADO and ADO.NET
        4. Nonfunctional Requirements
          1. Security
            1. Microsoft Passport
          2. Scalability and Availability
          3. Integrity and Transactions
        5. .NET Enterprise Servers
        6. Java and .NET
        7. Summary
      2. 2. Microsoft .NET
        1. Compilers and Language Support
          1. The Common Language Runtime
            1. A Closer Look at MSIL
            2. MSIL Verification
            3. Java Bytecodes
            4. Compiling MSIL to Native Code
          2. Cross-Language Development
            1. Combining Visual Basic and J#
            2. The Common Language Specification
              1. Common CLS rules
          3. Memory Management
            1. Garbage Collection
            2. Finalizers
            3. Deterministic Garbage Collection
          4. Integrating Unmanaged Code into .NET Applications
        2. Assemblies and Deployment
          1. The Joy of DLLs: The Movie
          2. .NET Assemblies
          3. Private Assemblies
          4. The Global Assembly Cache
            1. Strong Names and Version Numbers
            2. Deploying to the GAC
          5. Configuring an Application
            1. Binding Policies
            2. Downloading Assemblies
            3. Search Paths
            4. .NET Configuration Tool
        3. The .NET Framework Class Library
          1. Namespaces
            1. Frequently Used Namespaces
        4. .NET Remoting and the Web
          1. The .NET Remoting Architecture
          2. Remote Object Activation
          3. ASP.NET
          4. Web Services
        5. .NET Security
          1. Application Domains
          2. Role-Based Security
            1. Principals
            2. Declarative Security
            3. Imperative Security
          3. Code Access Security
            1. Evidence
            2. Permissions and Permission Sets
            3. Security Policy and Code Groups
            4. Requesting and Refusing Permissions
        6. Summary
      3. 3. Java and the Common Language Runtime
        1. Components and Java
          1. JavaBeans
            1. Business-Oriented JavaBeans
            2. JavaBeans and J#
          2. Components in .NET
            1. Defining Properties
            2. Defining Events and Delegates
            3. Event Arguments
            4. Consuming a .NET Component
        2. Java, J#, and the .NET Framework
          1. Packaging and Locating Classes
          2. The Java Class Hierarchy
            1. J# Objects
            2. Primitive Types
            3. Value Types
            4. Strings
            5. Arrays
            6. Exceptions
            7. Interfaces
          3. Other Issues
            1. Methods with Variable Numbers of Arguments
            2. Console I/O
            3. The ubyte Type
            4. Threads
            5. Omissions from the JDK
          4. Migrating to J#
            1. Migrating Source Code
            2. Converting Class Files
        3. Metadata and Attributes
          1. Reflection in .NET
            1. The System.Type Object and the System.Reflection Namespace
            2. Using Reflection
          2. Attributes
        4. Enterprise Java
          1. The Elements of J2EE
            1. Data Services in J2EE
            2. Business Services in J2EE
            3. User Services in J2EE
            4. The J2EE Infrastructure
            5. Transaction Management
          2. Comparing .NET to J2EE
            1. Data Services in .NET
            2. Business Services in .NET
            3. User Services in .NET
            4. The .NET Infrastructure
            5. Transaction Management
          3. The Java Pet Store
        5. Summary
      4. 4. Graphical User Interfaces
        1. Desktop GUIs
          1. Revisiting Java GUI Development
          2. The Windows Forms Library
        2. Porting Existing Java Applications
          1. Porting AWT Applications to .NET
        3. Writing a GUI Application Using the .NET Classes
          1. Creating the Windows Form
          2. Adding Controls to the Form
          3. Handling Events
          4. Using File Dialog Boxes
          5. Working with the System Clipboard
          6. Building and Running the Application
        4. Summary
    5. II. Managing and Manipulating Data
      1. 5. Processing XML
        1. Using XML in a .NET Application
          1. XML as a Data Format
          2. Roles for XML
          3. What Applications Need from XML Support
          4. Processing XML Data
          5. Support for XML in Visual J# and the .NET Framework
            1. Standards and Mechanisms Supported by the .NET Framework
            2. Classes in the .NET Framework
            3. Manipulating XML Files in Visual J#
        2. Single-Pass Processing of XML Documents
          1. Parsing XML Documents Using the XMLReader Class
          2. Processing XML Using an XMLTextReader Instance
            1. The XML Document
            2. Finding and Processing Elements and Attributes
            3. Traversing Hierarchies and Reading Content
          3. Other Options for Reading and Navigation
          4. Types and Namespaces
          5. Exception Handling
          6. Writing XML Documents Using the XmlWriter Class
          7. Escaping and Copying When Writing
        3. Validation and Entity Resolution
          1. Validating XML Documents
            1. Attaching a Schema or a DTD to an XML Document
            2. Handling Validation Errors
            3. Defining the Schema to Use
          2. Resolving Entities
        4. Processing XML Documents in Memory
          1. In-Memory Processing
          2. Loading XML into the XmlDocument Class
          3. Obtaining Information from a DOM Document
            1. Retrieving Information from a DOM Element
            2. Navigating the DOM Tree
            3. Searching the DOM Tree
          4. Treating a DOM Fragment as a Stream
        5. Writing and Manipulating In-Memory XML Documents
          1. Altering Content in a DOM Tree
          2. Making Substantial Changes to XML Documents
          3. Writing Out the DOM Tree
        6. XML and Data
          1. Links Between XML and ADO.NET Data
          2. Viewing XML as Relational Data
          3. Manipulating XML as Relational Data
          4. Viewing Relational Data as XML
        7. Summary
      2. 6. Transforming XML
        1. Transforming XML in .NET Applications
          1. The Need for Transformation
          2. The XSLT Processing Model
          3. Applying Transformations
          4. .NET Support for XML Transformations
            1. Standards and Mechanisms Supported by the .NET Framework
            2. Classes in the .NET Framework
        2. Applying Stylesheets to XML Documents
          1. Simple Transformations Using XslTransform
          2. Transformation Sources and Targets
          3. Transforming a DataSet
        3. Optimization and Partial Transformation
          1. Searching and Navigating Using XPath
          2. Optimizing XSLT Transformations
          3. Partial Transformations
        4. Parameterization and External Functionality
          1. Passing in Parameters
          2. Invoking External Functionality
            1. Extension Objects
            2. msxsl Script
        5. Summary
      3. 7. ADO.NET
        1. The ADO.NET Architecture
          1. ADO.NET Components
          2. DataSet Objects
          3. Connections and Data Adapters
        2. Connecting to a Data Store
          1. Connecting to a Data Source (OLE DB and SQL)
          2. Connections and Visual Studio .NET
          3. Connection Pooling
          4. Consuming Connection Events
        3. Executing Commands Against a Data Store
          1. Building Commands
          2. Using Parameters in Statements
          3. Invoking Stored Procedures
          4. Retrieving a Single Record from a Data Source
          5. Using a DataReader Object for Read-Only Data Retrieval
        4. Using DataSet Objects for Data Access
          1. Populating a DataSet Table from a Data Adapter
          2. Navigating a Typed DataSet
          3. Navigating an Untyped DataSet
          4. Manipulating and Updating a Data Store from a Data Adapter
          5. Defining Relationships and Constraints
        5. Transaction Management
        6. Working with XML and ADO.NET
          1. Writing a DataSet as XML
            1. DataSet.xml
          2. Writing DataRelation Objects as XML
          3. Inferring the DataSet Structure from XML
        7. Summary
    6. III. Developing for the Enterprise
      1. 8. Multithreading with .NET
        1. Threads and .NET
          1. Application Domains and Threads
          2. Creating Threads
          3. Threads and Security
          4. Passing Parameters to Threads
          5. Thread States
          6. Terminating Threads
            1. Interrupting a Thread
            2. Aborting a Thread
          7. Scheduling Threads
            1. Thread Priorities
            2. Background and Foreground Threads
          8. Threads and Unmanaged Code
            1. COM Apartments
            2. Calling Managed Code
        2. Synchronization
          1. Manual Synchronization
            1. Sync Blocks
            2. The Monitor Class
            3. The Interlocked Class
            4. The ReaderWriterLock Class
          2. Automatic Synchronization
            1. Method Synchronization
            2. Object Synchronization
          3. Static and Thread Data
        3. Interthread Communication
          1. Thread Notification
            1. Waiting
            2. Using Events
            3. Mutexes
          2. Timers
        4. Thread Pooling
          1. The ThreadPool Class
          2. Asynchronous I/O
        5. Summary
      2. 9. Basic Network Programming
        1. Sockets Essentials
          1. Connection-Oriented Sockets
            1. Connection-Oriented Servers
            2. Connection-Oriented Clients
            3. The TcpListener and TcpClient Classes
            4. Interoperability with JDK Sockets
          2. Data Transmission Issues
          3. Connectionless Sockets
          4. Blocking and Nonblocking Sockets
        2. Using Sockets Asynchronously
          1. The Poll and Select Methods
          2. Network Streams
        3. Web Network Programming
          1. Pluggable Protocols
          2. Requesting and Receiving Data Using HTTP
          3. Posting Data
          4. Processing Requests Asynchronously
          5. Using a WebClient Object
          6. HTTP Connection Management and Pooling
        4. Security over the Internet
          1. Authentication and Authorization
          2. Encryption
        5. Summary
      3. 10. Serializing Objects
        1. Serializing and Deserializing Data
          1. Formatting Data
          2. Deserialization
          3. Versioning
          4. Being Selective
        2. Advanced Serialization
          1. Customizing Serialization
          2. Handling Object Graphs
        3. XML Serialization
          1. XML Formatting
            1. Serializing Graphs as XML
            2. Namespace and Type Handling
            3. Controlling Serialization
          2. Deserializing an XML Stream
        4. Summary
      4. 11. .NET Remoting
        1. The Common Language Runtime Remoting Architecture
          1. Remote Objects
          2. The .NET Remoting Model
          3. The ObjRef Object and Proxies
          4. Messages, Channels, and Channel Sinks
        2. Programming with TCP Remoting
          1. Server-Activated Object Remoting
            1. Activation Modes
            2. Using Interfaces
          2. Client-Activated Object Remoting
            1. Configuration File Settings
            2. Activating Objects
          3. Managing Object Lifetimes and Leases
          4. TCP Remoting Security
          5. Remote Method Parameters
          6. Remote Events
        3. HTTP Remoting
          1. Remoting Server Hosting
          2. Hosting with IIS
          3. HTTP Remoting Security
        4. Customizing Remoting
          1. One-Way Remoting
          2. The RemotingServices Class
          3. Tracking Handlers
          4. Custom Channel Sinks and Channels
        5. Summary
      5. 12. Using Message Queues
        1. The Architecture of Message Queuing 3.0
          1. Queues, Servers, and Active Directory
          2. Transactional Message Queues
          3. Managing Queues
          4. System Queues
          5. Message Delivery
          6. Message Queuing Triggers
        2. Programming Message Queues
          1. Posting and Receiving Messages
            1. Messages and Serialization
            2. Attaching to a Queue and Creating a Message
            3. Using a Response Queue
            4. Posting a Message
            5. Receiving a Message
          2. Handling Messages
            1. Message Peeking
            2. Enumerating Messages
            3. Message Queue Concurrency
            4. Message Aging
            5. Correlating Messages
            6. Journaling Messages
          3. Managing Queues
            1. Message Queue Capacity
            2. Message Queue Connection Caching
            3. Message Queue Security
            4. Enumerating Message Queues
        3. Asynchronous Operations
          1. Receiving Messages Asynchronously
          2. Disconnected Queues
          3. Requesting an Acknowledgment
        4. Messaging in the Real World
          1. Reliability and Transactions
            1. Using Internal Transactions
            2. Using External Transactions
          2. Message Authentication and Encryption
            1. Authenticating Messages
            2. Sending and Receiving an Authenticated Message
            3. Encrypting a Message
          3. Messaging over HTTP
        5. Summary
    7. IV. Integrating with Windows
      1. 13. Integrating with Unmanaged Components
        1. Managed and Unmanaged Code
        2. Invoking Methods in Unmanaged DLLs
          1. Using J/Direct
            1. Isomorphic and Nonisomorphic Types
            2. Declaring Native Methods
            3. Marshaling Struct Objects
          2. The Platform Invoke Service
            1. Calling the System Restore API
            2. Defining Constants
            3. Mapping Data Structures
            4. Defining the System Restore API Methods
            5. Invoking the System Restore API
            6. Viewing the Results
          3. Other P/Invoke Issues
            1. Using Callbacks
            2. Calling Conventions
            3. Handling Polymorphic Parameters
            4. Handling Exceptions
            5. Security Constraints
        3. Calling COM Components
          1. Creating and Using an RCW
            1. The RCW Implementation
            2. Handling HRESULT Values
            3. Marshaling and Apartments
            4. Creating an RCW from the Command Line
          2. Sinking COM Events
          3. Using COM Objects Without Type Libraries
            1. Using Late Binding
            2. Manual Binding and Marshaling
        4. Integrating .NET Components into COM
          1. Designing .NET Components for COM Interop
          2. Creating a COM Callable Wrapper
          3. Testing the CCW
        5. Interoperability with Other Technologies
          1. The Real Solution: XML Web Services
        6. Summary
      2. 14. Serviced Components and COM+
        1. Using an Existing COM+ Component
          1. The FourthCoffee Components Revisited
          2. Configuring the Fourth Coffee COM+ Application
          3. Using the Fourth Coffee COM+ Application
          4. Subscribing to a Loosely Coupled Event
        2. Building a Serviced Component
          1. Serviced Component Basics
          2. Registering and Using the Serviced Component
        3. Features of Serviced Components
          1. Synchronization, Activities, and Context
          2. Static Methods
          3. Serviced Component Activation
            1. JIT Activation
            2. State Management
            3. Object Pooling
          4. Caching Shared State
          5. More About Transactions
            1. Specifying an Appropriate Isolation Level
            2. Transaction Duration
        4. .NET and COM+ Security
          1. Code Access Security Requirements
          2. The .NET Role-Based Security Model
          3. The COM+ Role-Based Security Model
          4. Implementing COM+ Security from .NET
          5. COM+ Imperative Security
        5. Asynchronous Components
          1. Creating a Queued Component
          2. Supporting Loosely Coupled Events
        6. Summary
      3. 15. Implementing Windows Services
        1. Controlling a Windows Service
          1. Displaying Service Information
          2. Starting and Stopping a Service
        2. Writing a Windows Service
          1. The Structure of a Service Application
          2. Understanding Installer Classes
          3. Creating a New Installer
          4. Adding a Service Description
          5. Installing and Testing the Service
          6. Uninstalling a Service
        3. Summary
    8. V. Building Applications for the Web
      1. 16. ASP.NET: A Better ASP
        1. Introducing ASP.NET
          1. Browser-Based Web Applications
          2. The ASP.NET Environment
          3. The Basic ASP.NET Programming Model
        2. HTML Forms and ASP Forms
        3. ASP.NET Web Forms
          1. The Server-Side Controls
          2. The Code Behind the Page
          3. Handling Events
          4. Client-Side Validation
        4. Migrating from ASP Pages
          1. Language and Code
          2. The User Interface
        5. Pages, Controls, and Data
          1. The Page Class
            1. Intrinsic Objects and Properties
            2. Events and Life Cycle
          2. Common Controls
            1. Forms and Selection
            2. Displaying Information
            3. Controlling Layout
          3. Creating Your Own Controls
            1. Creating a User Control
            2. Using a User Control
          4. Binding to Data
            1. Binding XML
            2. Binding SQL Data
        6. Building ASP.NET Web Applications
          1. Web.config
          2. Global.asax
          3. Deploying an ASP.NET Application
          4. Managing State
            1. Session Scope
            2. Remote Session State
            3. Application Scope
            4. Request Scope
            5. Cookies
          5. Error Handling
            1. Application-Wide Error Handling
            2. Page-Specific Error Handling
            3. Local Error Handling
            4. Generating Exceptions
          6. Security
            1. Authentication
            2. Authorization
          7. Caching
            1. Caching Application Data
            2. Output Caching
        7. Summary
      2. 17. Building a Web Service
        1. An Overview of Web Services
          1. What Is a Web Service?
          2. Web Service Technologies
            1. HTTP
            2. XML
            3. MIME
            4. SOAP
            5. WSDL
            6. UDDI
            7. New Technologies in the GXA
          3. Web Services in .NET
        2. Creating a Web Service
          1. A Simple Web Service
            1. Defining the Web Service
            2. Implementing the Web Service
            3. Testing the Web Service
            4. Compilation and Dependencies
          2. Creating a Web Service Using Visual Studio .NET
        3. Web Service Description and Data Types
          1. Exposing a Web Service Interface
            1. Namespaces in WSDL
            2. Type Definitions
            3. Messages, Parameters, and Parts
            4. Naming Parameters and Return Values
            5. Operations, Port Types, and Bindings
            6. Services and Ports
          2. Invoking the Service
          3. Passing Complex Data Types
            1. Representing Objects in WSDL
            2. Consequences of XML Serialization
            3. Nested Complex Types
            4. Polymorphism and Generic Object Conversion
          4. Passing DataSet Objects
          5. Passing XML Documents
        4. Creating an XML Web Service Application
          1. Web Services as ASP.NET Applications
            1. State Management
            2. Signaling Errors
            3. Securing a Web Service
          2. Transactions and Web Services
          3. Exposing Existing Applications as Web Services
            1. What Do You Have Already?
            2. Strategies for Exposing Functionality
        5. Summary
      3. 18. Creating a Web Service Client
        1. Web Service Clients
          1. The Client View of a Web Service
          2. Creating a Web Service Client Using Visual Studio .NET
          3. Going Beyond the Simple Client Scenario
            1. Handling Errors
            2. Retargeting the Proxy
            3. Handling Complex Types
            4. Handling Bulk Data
            5. Passing XML Documents
            6. Maintaining State
            7. Making Secure Calls
            8. Making Transactional Calls
            9. Making Asynchronous Calls
            10. Namespaces, WSDL, and Manual Proxy Generation
            11. Versioning and Updates
          4. Other Client Types
            1. Web Service Clients for .NET Remoting Services
            2. .NET Remoting Clients for Web Services
            3. Non-.NET Clients
        2. Dynamic Discovery of Web Services
          1. Discovering Services on a Server
            1. Static Discovery
            2. Dynamic Discovery
            3. Programmatic Discovery
            4. The Future of Discovery
          2. Discovering Services Through UDDI
        3. Summary
    9. A. About the Author
    10. SPECIAL OFFER: Upgrade this ebook with O’Reilly