- •Table of Contents
- •C# and the .NET Platform, Second Edition
- •Introduction
- •Part One: Introducing C# and the .NET Platform
- •Part Two: The C# Programming Language
- •Part Three: Programming with .NET Assemblies
- •Part Four: Leveraging the .NET Libraries
- •Part Five: Web Applications and XML Web Services
- •Obtaining This Book's Source Code
- •The .NET Solution
- •What C# Brings to the Table
- •The Role of the Assembly Manifest
- •Summary
- •Chapter 2: Building C# Applications
- •Summary
- •Chapter 3: C# Language Fundamentals
- •Defining Program Constants
- •Defining Custom Class Methods
- •C# Enumerations
- •Summary
- •The Second Pillar: C#'s Inheritance Support
- •Summary
- •Catching Exceptions
- •Finalizing a Type
- •Garbage Collection Optimizations
- •Summary
- •Chapter 6: Interfaces and Collections
- •Building Comparable Objects (IComparable)
- •Summary
- •Summary
- •Internal Representation of Type Indexers
- •Summary
- •An Overview of .NET Assemblies
- •Understanding Delayed Signing
- •Using a Shared Assembly
- •GAC Internals
- •Summary
- •Spawning Secondary Threads
- •A More Elaborate Threading Example
- •Summary
- •Summary
- •Object Persistence in the .NET Framework
- •The .NET Remoting Namespaces
- •Understanding the .NET Remoting Framework
- •All Together Now!
- •Terms of the .NET Remoting Trade
- •Testing the Remoting Application
- •Revisiting the Activation Mode of WKO Types
- •Deploying the Server to a Remote Machine
- •Summary
- •Control Events
- •The Form Class
- •Summary
- •Regarding the Disposal of System.Drawing Types
- •Understanding the Graphics Class
- •Summary
- •The TextBox Control
- •Working with Panel Controls
- •Configuring a Control's Anchoring Behavior
- •Summary
- •Chapter 16: The System.IO Namespace
- •The Static Members of the Directory Class
- •The Abstract Stream Class
- •Summary
- •The Role of ADO.NET Data Providers
- •The Types of System.Data
- •Selecting a Data Provider
- •The Types of the System.Data.OleDb Namespace
- •Working with the OleDbDataReader
- •Summary
- •Submitting the Form Data (GET and POST)
- •Some Benefits of ASP.NET
- •Creating an ASP.NET Web Application by Hand
- •The Composition of an ASP.NET Page
- •The Derivation of an ASP.NET Page
Part Five: Web Applications and XML Web Services |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
Chapter 18: ASP.NET Web Pages and Web Controls
This comprehensive text starts with a brief overview of the
C# language and then quickly moves to key technical and
This chapter begins your study of Web technologies supported under the .NET platform. ASP.NET is a architectural issues for .NET developers.
completely new approach for building Web applications and has absolutely nothing to do with classic (COM-based) ASP. For example, server-side scripting code has been replaced with "real" object-oriented
languages (such as C#, VB.NET, managed C++ and the like). This chapter introduces you to key
Table of Contents
ASP.NET topics such as working with (or without) code behind files, the role of ASP.NET Web controls
C# and the .NET Platform, Second Edition
(including the mighty DataGrid), validation controls, and interacting with the base class libraries from
Introduction
*.aspx files.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
ChapterChapter2 - Building19: ASPC# Applications.NET Web Applications
Part Two - The C# Programming Language
This chapter extends your current understanding of ASP.NET by examining various ways to handle state
Chapter 3 - C# Language Fundamentals
management under .NET. Like classic ASP, ASP.NET allows you to easily create cookies, as well as
Chapter 4 - Object-Oriented Programming with C#
application-level and session-level variables. However, ASP.NET also introduces a new state
Chapter 5 - Exceptions and Object Lifetime
management technique: the application cache. Once you examine the numerous ways to handle state
with ASP.NET, you then learn the role of the System.HttpApplication base class (lurking within the
Chapter 7 - Callback Interfaces, Delegates, and Events
Global.asax file) and how to dynamically alter the runtime behavior of your Web application using the
Chapter 8 - Advanced C# Type Construction Techniques web.config file.
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 20: XML Web Services
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
In this final chapter of this book, you examine the role of .NET XML Web services. Simply put, a Web
Part Four - Leveraging the .NET Libraries
serviceis an assembly that is activated using standard HTTP requests. The beauty of this approach is the
Chapter 12 - Object Serialization and the .NET Remoting Layer
fact that HTTP is the one wire protocol that is almost uni-versal in its acceptance and is, therefore, an
Chapter 13 - Building a Better Window (Introducing Windows Forms)
excellent choice for building platformand language-neutral distributed systems. You also check out
Chapter 14 - A Better Painting Framework (GDI+)
numerous surrounding tech-nologies (WSDL, SOAP, and UDDI) which enable a Web service and external
Chapter 15 - Programming with Windows Forms Controls client to communicate in harmony.
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Obtaining This Book's Source Code |
|
C# and the .NET Platform, Second Edition |
|
by Andrew Troelsen |
ISBN:1590590554 |
All of the code examples contained within this book (minus small code snippets here and there) are
Apress © 2003 (1200 pages)
available for free and immediate download from the Apress Web site. Simply navigate to
This comprehensive text starts with a brief overview of the
http://www.apress.com and look up this title by name. Once you are on the homepage for C# and
C# language nd then quickly moves to key technical and
the .NET Platform,architecturalSecond Edition,issues youf r .mayNET developersdownload.a self-extracting .zip file. After you unzip the contents, you will find that the code has been logically divided by chapter. Do be aware that the following icon:
Table of Contents
C# andSOURCEthe .N T Platform,is your cueSecondthatEditionthe example under discussion may be loaded into Visual Studio .NET for
CODE further examination and modification. To do so, simply open the *.sln file found in the
Introduction
correct subdirectory.
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Note All of the source code for this book as been compiled using Visual Studio .NET 2003. Sadly,
Chapter 2 - Building C# Applications
*.sln files created with VS .NET 2003 cannot be open using VS .NET 2002. If you are still
currently running Visual Studio .NET 2002, my advice is to simply create the appropriate project
Chapter 3 - C# Language Fundamentals
work-space, delete the auto-generated C# files, and copy the supplied *.cs files into the project
Chapter 4 - Object-Oriented Programming with C#
using the Project | Add Existing Item menu selection.
Chapter 5 - Exceptions and Object Lifetime Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Obtaining UpdatesC# and the .NETforPlatform,This BookSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
As you read over this text, you may find an occasional grammatical or code error (although I sure hope
Apress © 2003 (1200 pages)
not). If this is the case, my apologies. Being human, I am sure that a glitch or two may be present, despite
This comprehensive text starts with a brief overview of the
my best efforts. IfC#thislanguageis the case,and youthencanquicklyobtainmovesthe currentto key echnicalerrata listandfrom the Apress Web site (located once again on thearc"homepage"itectural issuesfor thisfor book).NET developersas well as. information on how to notify me of any errors you might find.
Table of Contents
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
ContactingC#Meand the .NET Platform, Second Edition
by Andrew Troelsen |
ISBN:1590590554 |
If you have any questions regarding this book's source code, are in need of clarification for a given
Apress © 2003 (1200 pages)
example, or simply wish to offer your thoughts regarding the .NET platform, feel free to drop me a line at
This comprehensive text starts with a brief overview of the
the following e-mailC# addresslanguage(toandensurethen quicklyyour messagesmoves to keydon'ttechnicalend up andin my junk mail folder, please include "C# SE" in the titlearchitecturalsomewhere!):issues<atroelsen@intertechfor .NET developers. -inc.com>.
Please understand that I will do my best to get back to you in a timely fashion; however, like yourself, I get
TablebusyoffromContentstime to time. If I don't respond within a week or two, do know I am not trying to be a jerk or don't C#careandtothetalk.NETto youPlatform,. I'm justSecondbusy (orEditionif I'm lucky, on vacation somewhere).
Introduction
So then! Thanks for buying this text (or at least looking at it in the bookstore, trying to decide if you will buy
Part One - Introducing C# and the .NET Platform
it). I hope you enjoy reading this book and put your newfound knowledge to good use.
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Take care,
Part Two - The C# Programming Language
ChapterAndrew3Troelsen- C# Language Fundamentals
Minneapolis, MN
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Part One:C#Introducinga d the .NET Platform,C#SecondandEditionthe .NET Platform
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages)
Chapter ListThis comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and architectural issues for .NET developers.
Chapter 1: The Philosophy of .NET
Table of Contents
Chapter 2: Building C# Applications
C# and the .NET Platform, Second Edition
Introduction
Part One - Introducing C# and the .NET Platform
Chapter 1 - The Philosophy of .NET
Chapter 2 - Building C# Applications
Part Two - The C# Programming Language
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
Chapter C#1:andThethe .NETPhilosophyPlatform, Second Editionof .NET
by Andrew Troelsen |
ISBN:1590590554 |
Apress © 2003 (1200 pages) |
|
Overview This comprehensive text starts with a brief overview of the C# language and then quickly moves to key technical and
Every few years ora chitecturalso, THE modernissues forday.NETprogrammerdevelope smust. be willing to perform a self-inflicted knowledge transplant to stay current with the new technologies of the day. The languages (C++, Visual Basic 6.0, Java), frameworks (MFC, ATL, STL), and architectures (COM, CORBA, EJB) that were touted as the silver
Tablebulletsof Contentsof software development, eventually become overshadowed by something better or at very least
C#somethingand the .NETnew.Platform,RegardlessSecondof theEditionfrustration you can feel when upgrading your internal knowledge base,
Introductionit is unavoidable. Microsoft's .NET platform represents the latest wave of (positive) changes coming from
PartthoseOnekind- Introducingfolks RedmondC# a .the .NET Platform
Chapter 1 - The Philosophy of .NET
The point of this chapter is to lay the conceptual groundwork for the remainder of the book. It begins with a
Chapter 2 - Building C# Applications
high-level discussion of a number of .NET-related atoms such as assemblies, the common intermediate
language (CIL), and just-in-time (JIT) compilation. In addition to previewing some key features of the C#
Chapter 3 - C# Language Fundamentals
programming language, you will also come to understand the relationship between various aspects of the
.NET Framework, such as the common language runtime (CLR), the Common Type System (CTS), and
Chapter 5 - Exceptions and Object Lifetime
the Common Language Specification (CLS). As you would hope, many of these topics are explored in
Chapter 6 - Interfaces and Collections
further detail throughout the remainder of this text.
Chapter 7 - Callback Interfaces, Delegates, and Events
ChapterThis chapter8 - Advancedalso providesC# TypeyouConstructionwith an overviewT chniquesof the functionality supplied by the .NET base class
Partlibraries,Threesometimes- Programmingabbreviatedwith .NETasAssthemblies"BCL" or alternatively as the "FCL" (being the Framework Class ChapterLibrary)9. Finally,- Understandingyou examine.NETaAssembliesnumber of helpful utilities (such as ildasm.exe and wincv.exe) that may be
used to investigate the structure of these libraries at your leisure.
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables
UnderstandingC# andthet .PreviousNET Platform,Stateecond ofEditionAffairs
by Andrew Troelsen |
ISBN:1590590554 |
Before examining the specifics of the .NET universe, it's helpful to consider some of the issues that
Apress © 2003 (1200 pages)
motivated the genesis of this new platform. To get in the proper mindset, let's begin this chapter with a
This comprehensive text starts with a brief overview of the
brief and painlessC#historylanguagelessona dtothremembern quickly movesour rootsto keyandtechnicalunderstanda the limitations of the previous state of affairs (afterarchitecturalall, admittingissuesyouforhave.NETadevelopersproblem .is the first step toward finding a solution). After completing this quick tour of life as we knew it, we turn our attention to the numerous benefits provided by C# and the .NET platform.
Table of Contents
C# and the .NET Platform, Second Edition
Life As a C/Win32 API Programmer
Introduction
Part One - Introducing C# and the .NET Platform
Traditionally speaking, developing software for the Windows family of operating systems involved using the
Chapter 1 - The Philosophy of .NET
C programming language in conjunction with the Windows API (Application Programming Interface).
Chapter 2 - Building C# Applications
While it is true that numerous applications have been successfully created using this time-honored
Part Two - The C# Programming Language
approach, few of us would disagree that building applications using the raw API is a complex undertaking.
Chapter 3 - C# Language Fundamentals
The first obvious problem is that C is a very terse language. C developers are forced to contend with
Chapter 4 - Object-Oriented Programming with C#
manual memory management, ugly pointer arithmetic, and ugly syntactical constructs. Furthermore, given
Chapter 5 - Exceptions and Object Lifetime
that C is a structured language, it lacks the benefits provided by the object-oriented approach (can anyone
Chapter 6 - Interfaces and Collections
sayspaghetti code?) When you combine the thousands of global functions and data types defined by the
Chapter 7 - Callback Interfaces, Delegates, and Events
raw Win32 API to an already formidable language, it is little wonder that there are so many buggy
Chapter 8 - Advanced C# Type Construction Techniques
applications floating around today.
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
ChaptLifer As10 - aProcesses,C++/MFCAppDomains,ProgrammerContexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
One vast improvement over raw C/API development is the use of the C++ programming language. In
Part Four - Leveraging the .NET Libraries
many ways, C++ can be thought of as an object-oriented layer on top of C. Thus, even though C++
Chapter 12 - Object Serialization and the .NET Remoting Layer
programmers benefit from the famed "pillars of OOP" (encapsulation, inheritance, and polymorphism), they are still at the mercy of the painful aspects of the C language (e.g., manual memory management,
ugly pointer arithmetic, and ugly syntactical constructs).
Chapter 15 - Programming with Windows Forms Controls
ChapterDespite16its-complexity,The Systemmany.IO NamespaceC++ frameworks exist today. For example, the Microsoft Foundation Classes
Chapter(MFC) 17provides- DatatheAccessdeveloperwith ADOwith.NETa set of existing C++ classes that facilitate the construction of Windows
Papplicationsrt Five - Web. TheApplicationsmain roleandof MFCXML Webis to wrapServicesa "sane subset" of the raw Win32 API behind a number of
Chclasses,pter 18magic- ASPmacros,.NET WebandPagesnumerousand WebcodeControlsWizards (i.e., AppWizard, ClassWizard, and so forth). ChapterRegardless19 - ASPof the.NEThelpfulWeb Applicationsassistance offered by the MFC framework (as well as many other C-based
windowing toolkits), the fact of the matter is C++ programming remains a difficult and error-prone
Chapter 20 - XML Web Services
experience, given its historical roots in C.
Index
List of Figures
ListLifeof TablesAs a Visual Basic 6.0 Programmer
Due to a heartfelt desire to enjoy a simpler lifestyle, many programmers have shifted away from the world of C(++)-based frameworks to kinder, gentler languages such as Visual Basic 6.0 (VB). VB is popular due to its ability to build complex user interfaces, code libraries (e.g., COM servers), and data access logic with minimal fuss and bother. Even more than MFC, VB hides the complexities of the raw Win32 API from view using a number of integrated code Wizards, intrinsic data types, classes, and VB-centric functions.
The major downfall of VB (at least until the advent of VB .NET) is that it is not a fully object-oriented language, but rather "object aware." For example, VB 6.0 does not allow the programmer to establish "is- a" relationships between types (i.e., no classical inheritance) and has no support for parameterized class construction. Moreover, VB 6.0 doesn't support the ability to build multithreaded applications (unless you are willing to drop down to low-level API calls, which is complex at best and dangerous at worst).
Life As a Java/J2EE Programmer
Enter Java. The Java programming language is (almost) completely object oriented and has its syntactic
C# and the .NET Platform, Second Edition |
|
roots in C++. As many of you are aware, Java's strengths are far greater than its support for platform |
|
by Andrew Troelsen |
ISBN:1590590554 |
independence. Java (as a language) cleans up the unsavory syntactical aspects of C++. Java (as a
Apress © 2003 (1200 pages)
platform) provides programmers with a large number of predefined "packages" that contain various class
This comprehensive text starts with a brief overview of the
and interface definitions. Using these types, Java programmers are able to build "100% Pure Java"
C# language and then quickly moves to key technical and
applications complete with database connectivity, messaging support, Web-enabled front ends, and a rich- architectural issues for .NET developers.
user interface.
Although Java is a very elegant language, one potential problem is that using Java typically means that
Table of Contents
you must use Java front-to-back during the development cycle. In effect, Java offers little hope of
C# and the .NET Platform, Second Edition
language independence, as this goes against the grain of Java's primary goal (a single programming
Introduction
language for every need). In reality however, there are millions of lines of existing code out there in the
Part One - Introducing C# and the .NET Platform
world that would ideally like to commingle with newer Java code. Sadly, Java makes this task problematic.
Chapter 1 - The Philosophy of .NET
ChapterPure Java2 -isBuildingsimply notC# Aappropriatelications for many graphically or numerically intensive applications. For Partexample,Two - Theif youC#areProgrammingbuilding a graphicsL nguageintensive product (such as a 3D-rendered video game), you will find
Java's execution speed will leave something to be desired. A better approach for such programs would be
Chapter 3 - C# Language Fundamentals
to use a lower-level language (such as C++) where appropriate. Alas, while Java does provide a limited
Chapter 4 - Object-Oriented Programming with C#
ability to access non-Java APIs, there is little support for true cross-language integration.
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
ChaptLifer As7 - aCallbackCOMInterfaces,ProgrammerDelegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
The truth of the matter is, if you are not currently building Java-based solutions, the chances are very good
Part Three - Programming with .NET Assemblies
that you have invested your time and energy understanding Microsoft's Component Object Model (COM).
Chapter 9 - Understanding .NET Assemblies
COM is an architecture that says in effect, "If you build your classes in accordance with the rules of COM,
Chapter 10 - Processes, AppDomains, Contexts, and Threads
you end up with a block of reusable binary code."
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
The beauty of a binary COM server is that it can be accessed in a language-independent manner. Thus,
Chapter 12 - Object Serialization and the .NET Remoting Layer
C++ programmers can build COM classes that can be used by VB. Delphi programmers can use COM
Chapter 13 - Building a Better Window (Introducing Windows Forms)
classes built using C, and so forth. However, as you may be aware, COM's language independence is
Chaptsomewhatr 14 -limitedA B tter Painting Framework (GDI+)
. For example, there is no way to derive a new COM type using an existing COM type (no
Chasupportter 15for- classicalProgramminginheritance)with Windows. Rather,FormsyouControlsmust make use of the more cumbersome "has-a"
Chaprelationshiper 16 - Theto reuseSystemCOM.IO Namespacetypes.
Chapter 17 - Data Access with ADO.NET
Another benefit of COM is its location-transparent nature. Using constructs such as application identifiers
Part Five - Web Applications and XML Web Services
(AppIDs), stubs, proxies, and the COM runtime environment, programmers can avoid the need to work
Chapter 18 - ASP.NET Web Pages and Web Controls
with raw sockets, RPC calls, and other lowlevel details. For example, ponder the following Visual Basic 6.0
Chapter 19 - ASP.NET Web Applications
COM client code:
Chapter 20 - XML Web Services
Index
' This block of VB 6.0 code can activate a COM class written in
List of Figures
' any COM-aware language, which may be located anywhere
List of Tables
' on the |
network (including |
your local machine). |
|||
Dim |
c |
as |
MyCOMClass |
' |
Location resolved using AppID. |
Set |
c |
= New MyCOMClass |
c.DoSomeWork
Although COM is a very dominant object model, it is extremely complex under the hood (at least until you have spent many months exploring its plumbing...especially if you happen to be a C++ programmer). To help simplify the development of COM binaries, numerous COM-aware frameworks have come into existence. For example, the Active Template Library (ATL) provides another set of C++ -based classes, templates, and macros to ease the creation of classic COM types.
Many other languages (such as Visual Basic 6.0) also hide a good part of the COM infrastructure from view. However, language support alone is not enough to hide the complexity of classic COM. Even when you choose a relatively simply COM-aware language such as VB 6.0, you are still forced to contend with fragile registration entries and numerous deployment-related issues (collectively termed DLL hell).
Life As a WindowsC# and the .DNANET Platform,ProgrammerSecond Edition
by Andrew Troelsen |
ISBN:1590590554 |
Finally, there is aAprlittlessthing© 2003called(1200 thepages)Internet. Over the last several years, Microsoft has been adding more Internet-awareThisfeaturescomprehensiveinto itstextfamilystartsof operatingwith a briefsystemsoverview. It ofseemsthe that the popularity of Web applications is everC#expandinglanguage and. Sadly,thenbuildingquickly movesa completeto k yWebtechnicalapplicationand using classic Windows DNA
architectural issues for .NET developers.
(Distributed iNternet Architecture) is also very complex.
Some of this complexity is due to the simple fact that Windows DNA requires the use of numerous
Table of Contents
technologies and languages (ASP, HTML, XML, JavaScript, VBScript, COM(+), as well as a data access C#APIandsuchtheas.NETADO)Platform,. One problemSecond Editionis that many of these items are completely unrelated from a syntactic
Introductionpoint of view. For example, JavaScript has a syntax much like C, while VBScript is a subset of Visual Basic
Papropert One. The- IntroducingCOM serversC# andthattheare.NETcreatedPlatformto run under the COM+ runtime have an entirely different look
Chapterand feel1 from- ThethePhilosoASP pageshy of .thatNETinvoke them. The result is a highly confused mishmash of technologies. ChapterFurthermore,2 - Buildingand perhapsC# Applicationsmore important, each language and/or technology has its own type system Part(thatTwotypically- The C#looksProgrammingnothing likeLanguagethe other type systems). An "int" in JavaScript is not the same as an "int" in
C, which is different from an "Integer" in VB proper.
Chapter 3 - C# Language Fundamentals
Chapter 4 - Object-Oriented Programming with C#
Chapter 5 - Exceptions and Object Lifetime
Chapter 6 - Interfaces and Collections
Chapter 7 - Callback Interfaces, Delegates, and Events
Chapter 8 - Advanced C# Type Construction Techniques
Part Three - Programming with .NET Assemblies
Chapter 9 - Understanding .NET Assemblies
Chapter 10 - Processes, AppDomains, Contexts, and Threads
Chapter 11 - Type Reflection, Late Binding, and Attribute-Based Programming
Part Four - Leveraging the .NET Libraries
Chapter 12 - Object Serialization and the .NET Remoting Layer
Chapter 13 - Building a Better Window (Introducing Windows Forms)
Chapter 14 - A Better Painting Framework (GDI+)
Chapter 15 - Programming with Windows Forms Controls
Chapter 16 - The System.IO Namespace
Chapter 17 - Data Access with ADO.NET
Part Five - Web Applications and XML Web Services
Chapter 18 - ASP.NET Web Pages and Web Controls
Chapter 19 - ASP.NET Web Applications
Chapter 20 - XML Web Services
Index
List of Figures
List of Tables