. NET Development Platform Research (II.)

Source: Internet
Author: User
Tags error handling exception handling implement include versions web services microsoft c visual studio
The main benefit of class libraries is that they encapsulate the most common features of the core Win32 API and the functionality of the plug-in SDK into a unified package. Class libraries are grouped and described in a clear and methodical manner, making it easier for developers to find most of the functionality they need for their applications.

In contrast, in the past few years, new functionality has been "tied" to the Win32 API, provided by a standalone API, such as DirectX for graphics, or a different SDK for XML and SOAP. The only logical grouping they can do is to sort alphabetically. As a result, using the Win32 API and various SDKs is often confusing, and developers must determine which of several similar APIs are best suited to their specific requirements.



Support for Web Services

The combination of the CLR and the class library makes it easier to develop Web services than it was before on Windows.

First, the CLR provides a more reliable basis for running server applications, including Web Services. Server applications typically have higher availability and security requirements than desktop applications, so they will benefit in particular from the ability of the CLR to catch errors and block malicious code. In addition, server applications typically require a long uninterrupted run, and therefore benefit from the defragmentation capabilities of the CLR. The defragmentation feature can limit memory leaks, otherwise long-running applications may run out of all available memory.



Mixed controllable and uncontrolled code



The collaboration capabilities of the Common Language Runtime (CLR) (Common language runtime Environment) allow developers to mix controllable code with the existing uncontrolled code in COM components (and the code in the Win32 Dynamic Connection Library (DLL)).

When a controllable code component invokes a COM component (the top level), the CLR generates a runtime callable wrapper (Runtime callable Wrapper) (RCW). The RCW acts as a proxy (or mediation) role for an uncontrolled COM component. The RCW process controls all interactions between components and COM components, including, but not limited to, the following:

• Translate and deliver data between the CLR and COM environments

• Frees the memory and other resources of a packaged COM component when a controllable code component is declared by the CLR defragmentation process.

• Translate errors from COM error return codes (HRESULT values) into CLR errors (called exceptions).

When COM component calls are written with controllable code (bottom). NET component, the CLR generates a package called a COM callable wrapper (CCW). Like the RCW, the CCW acts as a proxy or intermediary between uncontrolled COM code and controllable code. The CCW also implements standard settings for the functionality required by the COM component, which allows the control of the code component to look like a standard COM component.

CCW handles all the dependencies between an uncontrolled COM object and a controllable. NET component, including, but not limited to, the following.

• Moving and translating data between the two environments

• When a COM component is freed, the CLR releases the controllable code for the final defragmentation.

• Translate CLR Exceptions into COM return codes.



Second, class libraries provide all the code that developers need to create Web services or applications that use Web services. In particular, they provide code to translate between application data and XML, and to send and receive SOAP messages over Internet protocols. This allows developers to focus more on the logic of their own applications and try not to consider the details of how to implement a network protocol or read and write XML data.



Unified Platform:

The CLR and the class library also jointly address an important issue with Microsoft's current platform: All programming languages are not created in a balanced way. Each of Microsoft's programming languages has its own run-time infrastructure (for example, versions of several potential conflicts in Visual Basic [VB] runtime) and software libraries (such as the Microsoft C + + base class). This requires Microsoft to maintain these libraries and related tools such as debugger and wizard. An organization usually has to split a project, some of which are written by C + + programmers, while others are written by VB programmers. Any shortage of programmers can affect progress.

The. NET framework uses the following two methods to solve the problem of language partitioning.

Standardize data types. First, the. NET Framework provides standard internal descriptions and operations for the most commonly used data types, such as integers, real numbers, and text characters, and provides these types to all. NET language and the mechanism of the CLR extension. The establishment of this standardized data type and extensible model (the. NET Framework Common type System (CTS)) eliminates the need for each language to implement data types in its own unique and incompatible way.

Standardize application formats. Second, the. NET framework implements a standard application format-it has its own assembly of MSIL, metadata, and manifests. All. NET language compiler generates this format. By extracting information about MSIL from metadata, tools such as compilers, debuggers, and protocols can parse data from any source programming language.

Standardized data types and application formats allow developers to create class libraries that work in any programming language that understands their data types and formats, and such libraries contain all of Microsoft's. NET programming language and a number of Third-party vendor languages. In particular, the. NET Framework class Library uses only the CTS data type and is allocated in a standard application format. As a result, these class libraries can be used in any one. NET programming language applications.

(See the "Developing controllable Code" diagram.) )

The combination of the CLR and the class library provides Microsoft with a single running platform that supports running all programming languages and can be implemented with a set of common development tools. Microsoft has released a specification for the platform and the language it uses. (See the ECMA Standard and Windows lock-in.) In addition, the class library is to all. NET programming languages provide roughly the same basic set of functions so that programmers can work in any language they are most adept at.



. NET class library domain name space



. The API provided by the NET development platform is organized into a set of hierarchical domain name spaces with logical names. (This sketch shows a few of the more important classes.) This contrasts sharply with the Win32 API, which is a long list of simple feature names, which can be sorted alphabetically at most. Win32 With a rating system, developers will be able to locate the required functionality more quickly, and adding new APIs will not conflict with existing ones.

Class is based on the underlying class (bottom), and the underlying class has the following capabilities: Text Processing (system.text) network access (System. NET), as well as store lists and other datasets (System. Collections) and so on.

On top of the underlying class are more complex classes, such as data access (System. Data), which includes add.net and XML processing (System. XML).

The top level is the user interface library. Windows forms and drawing libraries, respectively, are system.win forms and system. Drawing provides a packaged Windows user interface, including GDI + and DirectX. System. The web contains class libraries for building asp.net applications that include Web services classes and Web Form user interface classes.



Developing controllable Code



Developers by putting their own application source code and from. NET class library to create a controllable code. These class libraries may include. NET development platform contains class libraries (such as ado.net and Windows Forms), and class libraries from third parties.

Next. NET compiler translates this code from a human-readable format to Microsoft Intermediate Language (MSIL). No matter what language you use, all of them. NET development platform compilers generate MSIL results.

In addition to MSIL,. NET compiler also produces metadata, which describes the components that make up the code. The Common Language Runtime (CLR) (Common language runtime Environment) uses this metadata to enhance security and to ensure that the correct version of any components it needs (reduce component conflicts, or "DLL Hell") is obtained.

Visual Studio. NET and other tools automatically encapsulate MSIL code into assemblies used in the CLR. Several MSIL files can be combined into a single assembly. (For a schematic overview of how a compilation is performed by the CLR, see the "Execute Controllable Code" sketch.) )



Comparison of 6.NET development platform and Java EE

As a competing application platform, Microsoft's. NET development platform and Sun's Java 2 Enterprise Edition (Java 2 Enterprise Edition) are very similar in intent and architecture, but they are completely different on the underlying implementations.



A similar goal:

. NET development platform and Java EE in the spirit essentially have similar goals:

Ø a program design model that makes it easier to reuse code components created by others eliminates the need to rewrite the underlying routines by providing developers with existing components, thereby improving developer productivity.

Ø enhances software reliability by eliminating or reducing the use of error-prone structures for development languages such as C, and by using a programming model that forces a clear definition of the interaction points between all code components (which isolates the impact of errors and makes error tracking easier).

Ø improves security by controlling what the application can or cannot do (for example, whether they can read/write disks), and by digitally signing at run time to verify that the code is written by a trusted entity and has not been changed.

Ø simplifies installation and uninstallation by embedding component descriptions within the code itself, including version information. This eliminates the idea of getting developers to "register" their code at installation--a major reason for the complexity and instability of previous installations--so that application software can be automatically installed when required, with no or little user or administrator intervention. In the case of the. NET development platform, it also allows different versions of the same component to coexist in a single system, without interfering with each other or with other applications.



A similar architecture:

Because the target is similar,. NET and Java EE Two development platforms also have a similar architecture. The corresponding architectural features are as follows:

Ø virtual machine: Designed to check, load, and execute programs in a tightly controlled "sandbox" (sandbox). By setting strict boundaries between what the program code can do and what not to do, the sandbox reduces the risk of accidental behavior by malicious code such as viruses and trust code. To enable this sandbox architecture, all programs are compiled from raw code into processor-independent mediation language--microsoft Intermediate Language (MSIL) or Java bit code. Then, with the participation of the Just-in-time (JIT) compiler, these mediation units are translated into native code for specific CPU types and operating systems. The virtual machine also provides basic services such as memory management to the program. NET's virtual machines are called Common Language Runtime (CLR), and Java EE uses the java-based virtual Machine (JVM) (Java VM).

Ø Class Library: Provide pre-written functionality to application developers, including: coding services (such as string manipulation and transaction processing), Network Services (Protocol processing), System management Services (security licensing and component merging), Server services (for Web page services, link e-mail), and services that connect external sources, such as database systems and data flows.

Ø a customized programming language: Built on C and C + +, including improvements such as strong typing and the possibility of improving developer productivity and reducing the likelihood of bugs appearing. However, there is no need to use these languages (C # for.) As long as there is a compiler that can translate the original source code into an intermediary code that the virtual machine can understand. NET or Java for EE) to write programs. The CLR now supports C #, Visual Basic, Jscript, Coblol, Fortran, Haskell, and Python (the tools developed by the tripartite with many other languages), and the JVM supports Java, COBOL, Ada, and Prolog.

Development environment for Dynamic Web pages running on a Web server: This allows developers to use the same platform for both creating desktop applications and creating web-based applications. NET uses ASP. NET and Java Server Pages (JSP) is used by EE.







7.. NET Development platform Tools:

Unlike the previous platform transitions from Win16 to Win32 APIs, transformations from Win32 to. NET development platforms include modifications to existing languages and tools, as well as the introduction of new languages. As a result, decide to use. NET development platform must not only change their platform strategy, but must also consider their language and tool strategies.



. NET Development Platform Language

There will be three new versions of Microsoft programming languages that support the CLR and class libraries: Visual Basic.NET, Visual C + +, and JScript.NET. They will also combine two new languages: Visual C # and Visual J #. Visual J # Enables Visual J + + developers to create controllable code using similar languages.

Microsoft has often pointed out that. The biggest difference between the net development platform and other programming environments, such as Java, is that. NET development platform supports a variety of programming languages. About. NET development platform and Java For more information, see Border content (". NET development platform and the comparison of Java EE ". Because. NET development platform supports different languages, programmers with different skills can create components by using the language they are best at, and these components can collaborate smoothly. But it also poses a problem-how development and project managers choose the language they use for their applications.

Every language that supports CIR and Microsof has different implementations and histories, and needs to be considered when making a choice. (for selection.) NET development Language Quick guide, see Border Content "select." NET language rule of thumb ". )



Visual Basic. NET

This new language has a syntax similar to the existing visual Basic (VB), designed to allow developers using VB to transition to. NET. However, unlike previous versions of VB, Visual Basic.NET uses the CLR and class libraries to replace similar VB components and Plug-ins. Vb. NET also has new, advanced features such as support for multithreading and structured exception handling. Although the removal of language habits such as the "OnError goto" type of error handling is a welcome change-this makes the application more robust, it means that current VB programmers cannot load and run their previous applications.

In fact, VB. NET has changed a lot compared with previous versions of VB and cannot be backward compatible. Microsoft is developing a tool to migrate VB source code into vb.net code, but this process cannot be completed automatically. The developer must manually check the migrated code, rewrite some parts, and carefully test the results.

However, developers do not have to migrate all the code at once: thanks to the CLR's collaboration capabilities, VB. NET can invoke VB code, and vice versa. This allows developers to incrementally migrate applications-for example, a vb.net application can incorporate some existing VB modules.

As the migration could not be completed immediately, Microsoft promised it would continue to support the current VB language (version 6.0), at least to VB. NET's third release, according to VB published the usual speed, it will probably wait until five or six years later.

Two variants of VB cannot be migrated to the. NET Development platform: One is visual basis Scripting Edition (VBScript) (Visual Basic Script Description version) for managing scripts, Active Server Pages ( ASP) (Active Server Page) and the script description language for dynamic Web content, and the other is visual Basic for Applications (VBA), which is used to customize the script description language for applications such as office. VBScript is already contained in vb.net, and VBA will continue to function as a macro programming language in office.

Microsoft says it's in the direction. NET development platform migration, the past developers using VB should use vb.net instead of C #. This is only a preliminary analysis of the conclusion, the specific situation also need to consider the developers use the broad extent of VB function:

• For most general VB programmers, most of the language changes are fairly straightforward. If the VB Developer's main experience is to use the existing VB components, then they should use vb.net for new application development, and not go to use C # up. The additional complexity of more rigorous object-oriented languages like C # is disproportionate to any small gain.

• Advanced VB Programmers-for example, developers who widely use functions such as "Win32 Declare" for direct calls to the underlying OS. With vb.net, they now have the ability to create the underlying components of an application, such as those used by other VB programmers. However, because they are designing components for use by other members of the team (even if the rest of the team continues to use vb.net), these component developers should also consider the benefits of switching to C # for component development.



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.