Microsoft. NET

Source: Internet
Author: User
Tags error handling exception handling garbage collection implement new features object model web services win32 error
Microsoft Keywords:. NET, XML (Extensible Markup Language), SOAP (Simple Object Access Protocol), Windowsdna, collection (assembly), Common language Runtime (CLR), IL (intermediate language), metadata (metadata), Name space (namespace), C #

I. Preamble

What is. Net? Different people have different ways of interpreting. Some people think that. NET is a new next-generation visual development environment; some people think. NET is a new development language for the Internet age---C #, some people think it is based on XML (Extensible Markup Language) and SOAP (Simple Object Access Protocol) of a new information exchange platform, is a future-oriented enterprise-level development platform. There are also those who think. NET is simply the evolution of Windowsdna technology. There are a lot of definitions like this, and they're all right, but they're all just related. Part of net. The first thing to be sure of. NET is a technological revolution. In today's society, technological progress occurs every day, but revolutions are not always there. In the history of Microsoft, from DOS to WINDOWS32 is a technological revolution, from Windows32 to WindowsNT is also a technological revolution. With the rapid development of the Internet, the difficulty of software development is gradually increasing, the existing development platform and development environment and technology, whether from the development of technology or from the development model is increasingly unable to meet the needs of the internet era of web-based applications and Web services, is in this environment, Microsoft has launched. NET, it can be no exaggeration to think that. NET is a revolution. On the back. NET in the in-depth discussion, we can appreciate this.

Two. The composition of the NET Framework



As shown in Figure 1,. The NET Framework consists of a number of aspects, the most important of which is the system service and the common language runtime (Common Language Runtime) throughout the structure. The common language runtime provides a number of services to simplify code development and application Deployment (deployment) while providing a wide range of services in terms of reliability and security. NET Framework also includes a series of base class libraries, which can be based on any of the base class libraries. NET programming language, the following discussion will find that the code-level reuse can be realized on this basis. At the top of the frame,. NET provides a range of components (note: It may be more appropriate to use the Word set (assembly) as a substitute for components in. net), greatly enriching development, whether it be developing windows-based applications or developing web-based applications.
First the discussion set (assembly), from the surface, seems to be in. NET Framework does not mention the concept of a set at all, but the collection is virtually ubiquitous and the collection can be considered a managed component. In the current development mode, the code is compiled to generate EXE files or DLL files, these DLLs or EXE are for a particular CPU, are directly in the way of machine code. The drawbacks of this approach have made almost everyone suffer---dll traps. In real life, often encountered such a situation, in the upgrade of a version of a DLL, found some old version of the function of the problem, and even memory conflicts, crashes and other problems. In the collection, because the generation of the code occurs in the form of an intermediate language (intermediate Language), it is not based on any particular CPU platform and automatically generates metadata (metadata) when generating the collection. This metadata exists in the collection as a manifest (manifest), and metadata can be used to describe the component itself, through metadata, to know what types and resources the component has. The version number of the collection is also included in the metadata. With such a component-a collection, there is no such thing as a DLL trap. So, the collection is. NET version control technology, the advent of collection technology allows developers and managers to rigorously implement version-dependent policies between different applications because collections can be self-describing and self-describing. You can also implement a true No side-effect installation. Because of the self description of the collection, concepts such as the registry will become obsolete. Under the. NET platform, all program installations will become copies, and serious registry garbage problems will not exist. On the other hand, because the collection becomes the smallest unit of the component that can be used, the collection is in the. NET's security domain also has the very important function.
Let's talk about system services, which contain a large number of underlying classes within. NET, which exist in the collection body. Each of the base classes is defined. NET platform, some of the potential properties. Properties similar to the underlying class are included in the same space (namespace). In the name space, the lowest and most common name space is the system name space, the class contained in the system name space is the base class, it is somewhat like the function of CObject class in MFC. In addition, the system name space includes the exception processing, garbage collection, console input and output, and so on a series of important features. Overall, if you want to use. NET platform, you need to interact with namespaces and the classes they have. For developers, you can derive your own class and namespace based on these namespaces. With the large number of services provided by system services, developers can develop internet-based programs in a more efficient, faster, and better way.
In the whole. NET Framework, the most important concept from a technical point of view is the common language runtime (Common Language Runtime), and the following are represented by the CLR. If you think of system services as. NET Framework, the CLR can be viewed as the core of the. NET Framework. For software developers, understand. NET is the key to understanding the CLR. For Windows developers, either the C RUNTIME Library or MFC or Java Virtual machine will be more or less familiar. In fact, the Windows operating system itself can be considered a collection of runtimes and libraries. The runtime, together with the library, provides services to the application, which in some ways greatly saves time and facilitates code reuse. Comparing COM's programming model to better understand the CLR's programming pattern, for COM, its programming idea is based on the type rather than the file-oriented. In this connection, the CLR is also adopting this approach. In the earliest Windows programming, when you need to invoke the interface of a DLL, you typically take advantage of the LoadLibrary function and then call the GetProcAddress function, as com appears, The CoCreateInstance and QueryInterface functions have changed all this. The CLR is also type-centric. Although the CLR is the same as COM in programming mode, it is not the same in the way it is implemented. The CLR overcomes some of the drawbacks inherent in COM itself, such as the type Information format is not uniform, private type information is not accessible, and so on. First, the concept of components in the CLR becomes a first class citizen. In COM, there are many ways to represent components, objects, classes, dynamic connection libraries can represent components, whereas in the CLR the concept of components is in the form of a collection (assembily), and for each type, COM is defined by a 128-bit UUID. In the CLR, in order to better ensure uniqueness, the 128-byte public key is used and the only type name in the local scope is maintained to provide a globally unique representation. When a client application invokes a collection, a 164-bit public key hash value is stored in the client application to ensure that the called collection is the correct collection. Second, there is only one metadata interchange format for the CLR. In COM programming, you need to define type information in IDL, and then use a specific language (c + + or Java) to implement it. In the CLR, developers can define and implement the type in any language. Third, the metadata is fully extensible. Any language can extend the type information of the CLR. Four, there are two types of systems in COM, iunkown and variant; all types in the CLR come from System.Object. TheFive, allows multiple inheritance of interfaces to occur in the CLR. All in all, just as you can't really understand windows without understanding COM technology, understanding the CLR is important for understanding. Net. In fact, from a certain point of view, the CLR is a huge leap forward for COM.
Three. NET's new features

. NET is a new kind of technology, so. NET also includes a lot of new features. Here are just a few of the more important features listed here.
(i), consistent programming model
In the. NET environment, all applications adopt a common object-oriented programming pattern, no longer the same as the Windows environment, both DLL functions and COM objects. (ii) simplified programming model
This is perhaps the most inspiring message for developers, and in the. NET environment, because of the role of the CLR, it is no longer necessary to master the GUIDs, IUnknown, AddRef, and other troublesome COM knowledge when programming.
(iii), running on multiple platforms
For any operating platform, just support. NET runtime can run. NET applications. This can be achieved by all Windows platforms now. You can even run on a non-Windows operating system in the future.
(iv) Support for multilingual synthesis
According to the COM principle, code reuse is based on the level of binary code. In the. NET environment, code reuse can be built at the source level, meaning that a class written in the C # language can be used directly in a language such as C + +. Reason. NET is so powerful that. NET provides a common set of type systems for all languages that support. NET programming.
(v), automatic resource management
It's no exaggeration to say that the problem with memory leaks is the biggest headache for all developers. In the. NET environment, this problem is completely resolved, and the automatic resource management feature has been added to the CLR. At the same time, due to the addition of resource recovery function, security is ensured to some extent, such as memory overflow attack will be effectively controlled.
(vi) Consistent way of error handling
It is believed that all WINDOWSSDK programmers are tired of the messy error handling in the Windows environment, WIN32 error codes, exception handling, HRESULT, and so on. All programs in the. NET environment adopt a unified error handling---generate exceptions.
(vii), security
As we already know,. NET is to cater to the next generation of the Internet environment of enterprise-level computing, the general access control can not meet its requirements, so in terms of security. NET has been improved more deeply than other systems, such as Windows. A validation check begins with loading a class, and code access security is enforced when accessing code and corresponding resources ... NET provides a set of mechanisms to judge roles and identify identity information, and to work across processes and machines to ensure that the required code is not compromised remotely. NET security is also deeply embedded in the CLR architecture to ensure the security of the application itself. These security mechanisms are a qualitative expansion of the existing operating system security mechanisms, compared to. NET has been further strengthened in security.
(eight), XML and SOAP Introduction
Recalling the design of distributed applications in the past, we have designed two-tier applications, based on protocols such as CORBA, IIOP, RMI, and DCOM. People are already familiar with such a distributed system. But the disadvantage of such a distributed system is that it is less flexible because it is designed so that the application is fixed on the server side. And the internet is a loosely connected, very distributed world. The original client/server structure is obsolete, thus proposing a new programming paradigm, and XML and SOAP make this pattern work well. XML and SOAP in. NET have been deeply integrated into it and become a very important part of it.
(ix), a new programming language C #
With. NET, Microsoft has also launched a new type of programming language C #. C # is as simple as VB, and as powerful as C + +. In some people's eyes, C # is a replica of java. There seems to be some truth in this argument, because C # is too Java-like. But correctly, C # is not a JAVA cloning, the introduction of C # is Microsoft in the study of C, C + +, JAVA, MODULA2, Smalltalk, and many other languages based on the introduction of the language, compared to JAVA, C # The biggest difference is that it is closer to C + +, while C # Also absorbed a lot of new concepts, such as C # is a component-oriented language, C # can be used to the maximum degree of integration with the XML protocol. At the same time, C # is very different from Java in terms of compilation. The introduction of C # with. NET is closely related.

Four. NET and the comparison of Java EE

In the computer world, new technologies are constantly emerging. Here's a comparison of Sun's Java-ee and Microsoft's. NET for next-generation enterprise computing.
The Java EE platform provides a component-based approach to designing, developing, assembling, and deploying enterprise applications. Java EE platform provides multi-layer distributed Application model, component reuse, consistent security model and flexible transaction control. Also ensure that your platform-independent, component-based Java solution is not tied to the products and APIs of any one vendor. Through the above discussion we can see the starting point of designing new technology should say. NET and Java EE are very similar. But these two kinds of technology both in the realization method and the concrete realization technology both have the very big and even opposite difference point.
The first thing to be pointed out is. NET is definitely not a simple, improved Windows operating system. Because according to Microsoft's design idea, any operating platform can run. NET program as long as the CLR is installed.
1, in the development language,. NET support is broad, C + +, VB, C #, Perl, COBOL and so on are supported, developers can easily find the appropriate language. and Java-EE only supports the java-based language. This means that the Java EE in the language of the choice of the face is relatively narrow. Of course, C # is the most important language of. NET support, and in contrast to Java, C # supports JIT (just-in-time) compilation, and Java is based on interpretation. At the same time, Microsoft provides different JIT-compiling methods for different platform environments. Microsoft provides compression for a mobile computing environment similar to Windows CE. NET Framework, the corresponding also provides the Econojit (economical compiler). In the general desktop environment, Microsoft provides a standard compiler. On the other hand, C # will become an industry standard because ECMA (the European Computer Manufacturers Association) is hosting C #, and the Java language is just from sun.
2, Java-EE supports XML/SOAP, while. NET supports it. In terms of standard openness, xml/soap is better than the former. XML is proposed by the World Wide Web organization, supported by many manufacturers, is the standard of content representation on the next generation Internet, XML can effectively express various knowledge on network, and provide new carrier for exchanging and computing information. The function of XML in relation to network computing can be compared with the function of the ASCII code in the initial stage of computer. XML can also be said to be the standard Code of Network information, it represents not symbolic information, but knowledge of the block content. This standard language, though not a programming language, represents a bright future for interoperability on the next generation of networks. Speaking of this, I can't help but remind people of "that year" to the JAVA mania. Indeed, Java has a very tempting intention, so many people can in such an ideal inspiration for the imagination of the various systems of interoperability between the active development. In practice, however, Java has not become a successful business computing tool for people to imagine, and there is no substantial technological advance. Java tries to interoperate from the perspective of a unified computing platform, but this may always be a dream. What is truly interoperable can only be the standard and common data Description language. and the SOAP protocol itself is being developed jointly by business giants such as Microsoft and IBM. It all shows. NET technical standards of openness is good.
3,. NET's SOAP protocol ensures that components on one platform can exchange information with components on the. NET platform.
4, the most important point is that under the existing conditions, a variety of so-called cross-platform, "compile once, multiple runs" and other slogans are only commercial fry. The chief designer of Java, James Goslin, has expressed the view that the slogan "compile once and run multiple times" is just a good idea. This means that development based on one development platform is unavoidable, and if you are using Java to develop business programs based on IBM's WebSphere, it is basically fixed on this platform. This is not true of the 100% pure slogans that Java claims, and of course, C #.
5, one of the great benefits of developing programs on the. NET platform is that you can achieve real "code reuse." Because in the design. NET platform, an important idea is to separate the runtime from the specific language. All resource management, memory allocation, variable types, etc. are handled by the runtime, so that the classes written in C # can be used directly in C + + programs. In this case, just based on. NET platform, the past programs do not have to adopt a new language and make very big changes. Java is Java, which mixes the runtime with the specific language.
To sum up, Java EE and. NET each have their own advantages and disadvantages. Both are excellent platforms for developing enterprise computing software. But just as different people have different hobbies, in the future development, or according to their specific needs and determine the specific application platform.

A few questions about. net
Through the above analysis, we can feel. NET is indeed a technological revolution. But after research, it will be right. NET produces several questions.
1, is the real cross-platform?
According to Microsoft, any operating platform that loads the common language runtime (CLR) can do "write once, compile once, run anywhere." In other words, the CLR is very important for. NET programs. Although Microsoft's research and Development Center is developing a CLR template, this is the requirement. But at least the first version of the future appears. NET does not have this functionality, it simply supports the Windows platform of the past. Even if the CLR template is merged in the future, it is doubtful whether it can be cross-platform.
2, COM (Component Object Model technology) really disappeared?
At the PDC (Developer conference) in 2000, Microsoft said that the troublesome COM programming pattern would disappear completely, and that the Clr,iunknown interface would not appear. In this respect, it is not too optimistic to know that COM is the basis of Windows, and it also talks about the relationship between the CLR and COM technology. It should be said that COM does not disappear, but has made very big progress (at least in the programming method).
3, can a code-level multi-language interaction really do that?
Multilingual interaction is understandable for languages such as visual Java, Visual Basic, C # that develop managed code (managed code) can be implemented. But the question is how to do with the very powerful function of C + +, the use of pointers in a very wide range of languages really do code reuse where?

Six, the subsequent

. NET as a new revolutionary technology to launch is exciting. Can believe, along with. NET's formal application, it will greatly change our development model. As a software developer,. NET will bring us greater opportunities and challenges. Instead of pond, it's better to retreat. After all, the wolf is going to come in, we only from now on to do all the preparation to find the most suitable for their own software development path, in order to be technically not subject to people.

Resources:
http://www.microsoft.com/net/whitepaper.asp
Http://msdn.microsoft.com/msdnmag
http://java.oreilly.com/


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.