. NET Framework and COM

Source: Internet
Author: User
Tags connection pooling error handling ole web services visual studio
The. NET Framework reusable software is not a new concept. For eight of years, people have been using various forms of Component object models (COM). It turns out that it is the most successful reusable software model. COM introduces the concept of "component"-a reusable block of code that can be combined to combine the functions of multiple independent functions to extend to applications such as Microsoft Word.

Most developers have a deep experience with COM functionality when using OLE. OLE is a set of features that are based on COM, enabling users to embed one document into another. The feature itself doesn't seem fascinating, but it works the other way: When users click an embedded Excel document when they paste an Excel document into a Word document, OLE converts Word's toolbars and menus to Excel's toolbars and menus.

From a developer's perspective, COM provides code reuse by introducing several well-defined interfaces, such as IUnknown, through which the development tools can query the functionality of a component and add them to the tool. This is like a control in the Visual basic® development system Toolbox that can be dragged onto a form. In fact, each control represents hundreds or even thousands of lines of code, can easily be encapsulated in the "black box", developers need to call their functions directly.

One of the problems that developers find inconvenient when using COM is that they must write additional code to convert the business logic program into reusable components, and many interfaces must be implemented to make this transition. Most importantly, COM requires developers to handle complex issues manually, such as emptying memory used by components that are no longer in use, computing the number of components used, creating or undoing threads and processes, and handling versioning issues.

One might think it would be nice to let developers do this kind of work in person, but there are a few drawbacks. First of all, it is very difficult to do all of these things for developer one by one, often prone to error: Cause application errors, system crashes, and scary "DLL Hell." In addition, the rigorous writing of all this additional code will reduce the productivity of the developer and lead to a postponement of the listing.

This is especially true for developers who use visual c++® development systems. This is not a serious situation for developers who use Visual Basic. Visual Basic abstracts and simplifies many of the concepts of COM and is the most productive and popular development environment in the world, but its limitations lie in the fact that it has to shield some of the functionality of COM to developers in order to achieve this high productivity.

The. NET Framework introduced by Microsoft at the Professional Developers Conference (PDC) in 2000 can automatically be "smart stitching" in software authoring, allowing developers to concentrate on writing business logic without having to write COM infrastructure.

What is. NET Framework?

. NET Framework is a multilingual component development and execution environment that consists of the following three major components:


The common language runtime. This name does not accurately reflect all of its functionality. In fact, the common language runtime plays a very important role in the process of component development and operation. During the operation of a component, the runtime is responsible for managing memory allocations, starting or deleting threads and processes, enforcing security policies, and meeting the requirements of the current component for other components. During the development phase, the runtime's role has changed: the runtime is significantly more automated than today's COM (for example, it automates memory management), so the developer's work becomes very easy. In particular, mapping capabilities will drastically decrease the amount of code written by developers who convert business logic programs into reusable components. The concept of runtime is not novel to a programming language: Virtually every programming language has its own runtime. The Visual Basic development system has the most obvious runtime (named VBRun), and Visual c++® has a runtime like visual foxpro®, jscript®, SmallTalk, Perl, Python, and Java. That is, MSVCRT. NET Framework is that it provides a unified programming environment across programming languages, which is also the root cause of its unique role.

Unified Programming class. NET Framework provides developers with a unified, object-oriented, hierarchical, extensible Class Library set (API). Today, C + + developers use the Microsoft Base Class library, where Java developers use the windows® base Class library, and the Visual Basic API set used by Visual Basic users. Just a simple use,. NET Framework unifies Microsoft's current various kinds of frameworks. This allows developers to program smoothly without having to learn a variety of frameworks. Much more than that, by creating a common API set across programming languages. NET Framework enables cross language inheritance, error handling, and debugging. In fact, all programming languages from JScript to C + + are mutually equal, and developers are free to choose the ideal programming language.

Active Server Page (asp+). Asp+ is used. NET Framework, which provides a Web application model that consists of a set of controls and a basic structure. With it, the construction of Web applications becomes very easy. Developers can directly use the asp+ control set, which encapsulates a common set of widgets (such as text boxes, Drop-down menus, and so on) that are used for the Hypertext Identification Language (HTML) user interface. In fact, these controls run on the Web server, which converts the user interface into HTML format before sending it to the browser. On the server, the control is responsible for providing the Object-oriented programming model to Web developers, which provides rich functionality for object-oriented programming techniques. Asp+ also provides basic infrastructure services, such as session state management and process restart services, that greatly reduce the amount of code developers will write and increase the reliability of their applications. The asp+ also allows developers to provide software as a service. By using the Asp+ Web Services feature, asp+ developers need only simple business logic programming, and the asp+ infrastructure is responsible for providing services through Simple Object Access Protocol (SOAP).

The relationship with COM

. NET Framework is designed to make COM development easier. One of the hardest things about COM's development process is to deal with COM infrastructure. Therefore, in order to simplify COM development,. NET Framework has virtually automatically handled all tasks that the developer appears to be closely related to "COM", including reference calculations, interface descriptions, and registration.

It must be recognized that this does not mean. NET Framework component is not a COM component. In fact, COM developers who use Visual Studio 6.0 can invoke the. NET Framework components and, in their view, are more like COM components that have IUnknown data. Instead, the. NET Framework developer who uses Visual Studio.NET sees the COM component as a. NET Framework component.

To avoid misunderstandings, this relationship needs to be specifically illustrated: COM developers must manually do things that most. NET Framework developers can automate at run time. For example, the security module of a COM component must be handwritten and the memory consumed by the module cannot be automatically managed, and when the COM component is installed, the registration entry must be placed in the Windows registry. For the. NET Framework, the runtime implements the automation of these features. For example, the component itself is self-describing, so it can be installed without registering in the Windows registry.

Relationship to COM +

When COM is combined with Microsoft Transaction Server (MTS) and Distributed COM (DCOM), it becomes COM +. COM + provides a set of services that are oriented to the middle tier. In particular, COM + provides process management capabilities and database and object connection pooling capabilities. In future releases, it will also provide a feature called partitioning-a more powerful process isolation feature designed specifically for application service providers.

COM + services are primarily geared toward middle-tier application development and provide reliability and scalability primarily for large distributed applications. These services are right. NET Framework to provide services to supplement; NET Framework classes for direct access to these services.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.