New Features of. NET Framework 4.0

Source: Internet
Author: User
Tags smtpclient

Note that. NET Framework 4 introduces an improved security mode. For more information, see security changes in. NET Framework 4.

Specifically, this article will introduce. NET framework 4 has the following new features and improved features: application compatibility and deployment \ new kernel functions and improvements \ managed extension framework \ parallel computing \ Network Programming \ Web Development \ Client development \ data \ communication and workflow

  I. Application compatibility and deployment

In addition to some improvements in security, standard compliance, correctness, reliability, and performance,. NET Framework 4 is highly compatible with applications built based on earlier. NET Framework versions.

. NET Framework 4 does not automatically use the current version of the Public Language Runtime Library to run applications built using earlier versions of. NET Framework. To run previous applications under. NET Framework 4, you must use the target. NET Framework version specified in the attributes of your Visual Studio project.RecompileYour application, orThe configuration file uses elements to specify the supported runtime libraries..

The following sections describe Application Deployment improvements.

(1) Customer Configuration

. NET Framework 4 supports more platforms than earlier versions, and provides quick deployment experience for your Windows Presentation Foundation (WPF), console, or Windows Forms applications. For more information, see. NET Framework client configuration.

(2) parallel execution in processes

This feature enables applications to load and start multiple versions of the. NET Framework in the same process. For example, you can run an application that loads a plug-in (or component) in the same process. The program itself is based on. NET Framework 2.0 SP1 and the plug-in is based on. NET Framework 4. Earlier components will continue to use earlier. NET Framework versions, while new components will use new. NET Framework versions.

 Ii. New kernel functions and Improvements

The following sections describe the new features and improved features provided by the Runtime Library and basic library of the common language.

(1) diagnosis and Performance

Earlier versions. the. NET Framework does not provide a way to determine whether a specific application domain is affecting other application domains, because the operating system APIs and related tools (such as Windows Task Manager) are precisely designed at the process level. Starting from. NET Framework 4, you can get the estimation information of CPU and memory usage in each application domain.

You can monitor the CPU and memory usage of each application domain. You can monitor application domain resources through hosting, local host APIs, and Windows event tracking (ETW. When this feature is enabled, it collects statistics for all application domains throughout the lifecycle of a process. For details about this topic, refer to the introduction to the new appdomain. monitoringisenabled attribute.

Now, you can access ETW events for diagnostic purposes to improve performance. For more information, see the clr etw event and control. NET Framework log articles. For more information, see performance counters and In-process parallel applications.

Finally, the system. runtime. exceptionservices. handleprocesscorruptedstateexceptionsattribute attribute allows you to handle exceptions that display crashed process statuses in managed code.

(2) garbage collection

. NET Framework 4 supports background garbage collection. This function replaces parallel garbage collection in previous versions to provide better system performance. For more information about this content, see the article garbage collection basics.

(3) code contract

The Code contract function allows you to specify contract information that is not described by a method or type signature. The classes contained in the new namespace system. Diagnostics. Contracts provide a language-independent method that uses preconditions, post conditions, and object constants to express encoding assumptions. These contracts can improve testing through runtime checks, support static contract verification, and support document generation. For more information about this content, see Code contract.

(4) only use the design-time interoperability assembly

Today, you no longer need to carry the main interoperability assembly (PIA) to deploy applications that interoperate with COM objects. In. NET Framework 4, the compiler can embed type information from the set of interoperability programs, and can select only the types actually used by those applications (such as a plug-in. Type security is guaranteed by the runtime of Public languages. For more information, see articles using the com type in managed code and Walkthrough: embedding type information (C # and Visual Basic) from a Microsoft Office program.

(5) Dynamic Language Runtime

Dynamic Language Runtime (DLR) is a new runtime environment, which adds a set of services for dynamic languages to CLR. DLR makes it easier to develop dynamic languages running on the. NET Framework and adds dynamic features to static languages. To support DLR, a new namespace system. Dynamic is added to the. NET Framework.

By introducing new types that describe the control flow, such as system. LINQ. Expressions. loopexpression and system. LINQ. Expressions. tryexpression, the expression tree function is further extended. Note that these new types are only used by Dynamic Language Runtime (DLR) and cannot be used by LINQ.

In addition, some new classes that support the. NET Framework infrastructure are added to the system. runtime. compilerservices namespace. For more information, see Dynamic Language Runtime overview.

(6) Coordination and reverse change

There are several generic interfaces and delegation that now support the covariant and reverse variant functions. For more information about this content, see covariant and reverse change in generics.

(7) biginteger and plural

The new system. numerics. biginteger structure is an integer data type of any precision. It supports all standard integer operations, including bit operations. Biginteger can be used in any. NET Framework language. In addition, some new. NET Framework languages (such as F # And ironpython) have built-in support for this structure.

The new system. numerics. complex structure is used to describe a plural number and supports the arithmetic and triangular operations of the plural number.

(8) tuples

. NET Framework 4 introduces the system. tuple class for creating tuples containing structured data. In addition, a generic tuples class is provided to support tuples with 1 to 8 components. To support nine or more component tuples, a generic tuples class is provided. This class uses seven type parameters, and the 8th parameters can be any tuples.

(9) Improvements to the file system enumeration Function

In. NET Framework 4, a new file enumeration method is added to further improve the performance of applications that access giant file directories or traverse large files. For more information, see How to: Enumerate directories and files.

(10) memory ing File

The. NET Framework now supports memory ing files. You can use a memory ing file to edit very large files and create shared memory for inter-process communication.

(11) 64-bit operating systems and processes

You can use the environment. is64bitoperatingsystem and environment. is64bitprocess attributes to identify 64-bit operating systems and processes.

When you open the base key, you can use the Microsoft. win32.registryview enumeration to specify a 32-bit or 64-bit registry view.

(12) Other new functions

The following lists the new features, improvements, and conveniences of the Common Language Runtime Library and the basic class library. Some of these functions are provided based on customer suggestions.

To support cultural-sensitive formats, the system. timespan structure includes new loads for tostring, parse, and tryparse methods, as well as new loads for parseexact and tryparseexact methods.

The new string. isnullorwhitespace method can determine whether a string is null, empty, or contains only blank characters. A new overload of the string. Concat and string. Join methods is added. These two overload methods can concatenate the members in the system. Collections. Generic. ienumerable set.

The string. Concat method allows you to concatenate each element in an enumerated set without converting these elements into strings in advance.

Two more convenient methods are added: stringbuilder. Clear and Stopwatch. Restart.

When the number of strings is determined, the performance of string. Concat is higher than that of stringbuilder. In fact, the larger the number of strings, the more obvious the gap.

When the number of strings is relatively small (about 5-6 in terms of data), the performance of stringbuilder is not faster than that of common connection operations. Therefore, it is inappropriate to use stringbuilder anywhere.

The New Enum. hasflag method determines whether to set one or multiple fields (FLAG) in an enumerated value ). The enum. tryparse method returns a Boolean value indicating whether a string or integer is successfully parsed.

The system. environment. specialfolder enumeration contains several new folders.

Now, you can use the copyto method in the class inherited from the system. Io. Stream class to easily copy a stream to another stream.

The new overloaded path. Combine method allows you to merge multiple file paths.

The new system. iobservable <(of <(T>) and system. the iobserver <(of <(T>)> interface provides a more general mechanism for notification based on push technology.

The system. intptr and system. uintptr classes now support addition and subtraction operators.

Now, you can package the type in a system. Lazy <(of <(T> class to implement delayed initialization for any custom type.

The new system. Collections. Generic. sortedset class provides a self-balancing tree that maintains the data sorting order after data is inserted, deleted, and searched. This class implements the new system. Collections. Generic. Iset interface.

The compression algorithms for the system. Io. Compression. deflatestream and system. Io. Compression. gzipstream classes are further improved so that the compressed data does not expand. In addition, the 4G size limit on the compressed stream is also removed.

A boolean reference can be used in the new overloaded monitor. Enter (object, Boolean) method. This variable is automatically set to true only when the monitor successfully enters.

You can use the thread. Yield method to allow the calling thread to give the current execution context to another thread that is ready to run on the current processor.

The system. guid structure now contains the tryparse and tryparseexact methods.

The new Microsoft. win32.registryoptions enumeration allows you to specify an unstable registry key, which no longer exists after the computer restarts.

Registry entries are no longer limited to the maximum length of 255 characters.

  Iii. Managed extension framework

Managed scalability framework (MEF) is a new library in. NET Framework 4 that helps you build scalable and composite applications. MEF allows you to specify the extension points in an application, provide services to other extended applications, and create components used by scalable applications. MEF also supports easy retrieval of available Parts Based on metadata without loading the corresponding assembly for these parts. For more information about this content, see managed scalable frameworks. For a list of MEF types, see system. componentmodel. Composition namespace.

  Iv. Parallel Computing

. NET Framework 4 introduces a new programming mode for writing multithreading and asynchronous code, which greatly simplifies the programming of applications and library developers. This new mode allows developers to write efficient, fine-grained, and scalable parallel code in a natural way without directly using threads or thread pools. The new system. Threading. Tasks namespace and other related types support this new mode. Parallel LINQ (Plinq), as a parallel implementation of LINQ to objects, can support similar functions through declarative syntax. For more information, see. NET Framework parallel programming.

 V. Network Programming

Network Programming improvements include:

Security improvements for Windows authentication are reflected in several classes, including system. net. httpwebrequest, system. net. httplistener, system. net. mail. smtpclient, system. net. security. sslstream and system. net. security. negotiatestream. Extended protection can be used for applications running on Windows 7 and Windows Server 2008 R2. For more information, see use extended protection integrated Windows authentication.

Supports Network Address Translation (NAT) traversal using IPV6 and Teredo. For more information, see use IPv6 and Teredo for NAT traversal.

The new network performance counter provides information about the httpwebrequest object. For more information, see network performance counters.

In the system. net. httpwebrequest class, you can use the 64-bit header structure by reloading the addrange method. The new attributes defined in the system. net. httpwebrequest class allow an application to set many HTTP headers. You can use the host attribute to set the header value of an HTTP request independent of the request URI.

Provides Secure Socket Layer (SSL) support for system. net. Mail. smtpclient and related classes.

Provides improved support for mail headers in the system. net. Mail. mailmessage class.

An empty password can be used in one encryption. You can use the system. net. servicepointmanager class and encryptionpolicy attributes to specify the Encryption Policy. The constructor of the system. net. Security. sslstream class uses a system. net. Security. encryptionpolicy class as the parameter.

For Password-based authentication mode, such as in system. net. the basic, digest, NTLM, and Kerberos authentication modes defined in the networkcredential class provide certificate support. To improve security, we can now regard the password as an implementation of the system. Security. securestring class, rather than a simple system. string class instance.

Now, you can specify how to use the percentage encoding value in the system. Uri and system. net. httplistener classes to convert and normalize a URI. For more information, see system. net. configuration. httplistenerelement, system. configuratio. schemesettingelement, system. configuration. schemesettingelementcollection, system. configuration. urisection, and other classes.

 Vi. Web Development

ASP. NET version 4 introduces some new features in the following aspects:

Core Service, including a new API that allows you to expand the cache, supports compressing session status data and a new application preload Manager (auto start function ).

Web forms, including ASP. net routing provides more integrated support, enhanced support for web standards, and updated browser support, adding some new functions for data controls, and added some new features for view status management.

Web forms controls provide a new chart control.

MVC framework, including new auxiliary methods for views, support for partitioned MVC applications, and asynchronous controllers.

Dynamic data, including support for existing web applications, full support for many-to-many relationships and inheritance, support for field templates and attributes, and enhanced data filtering.

Added additional support for client-centric Ajax applications in the Microsoft Ajax library.

Visual Web Developer includes improved JScript-based intelligent Awareness Support, new automatic and complete code snippets for HTML and ASP. NET tags, and enhanced CSS compatibility support.

In terms of deployment, new support tools are provided for automated typical deployment tasks.

Multi-objective, including better filtering support for features that cannot be available in the target version of the. NET Framework.

For more information about these features, see ASP. NET 4 and new features of Visual Web Developer.

  VII. Client development

Windows Presentation Foundation

In. NET Framework 4, Windows Presentation Foundation (WPF) has changed and improved many aspects, including controls, graphics, and XAML. For more information, see WPF 4 new features overview.

 8. Data

(1) ADO. net

ADO. net object framework provides new functions, including persistence-ignorant objects. Note: this type of object has the ability to convert a poco object structure into an object information structure and store it in the Information Library without having to create entity information in the DBMS .), You can use this function to create code at the LINQ query and custom object layer. For more information, see ADO. net new features.

(2) Dynamic Data

For ASP. NET 4, dynamic data support is further enhanced to provide you with more powerful functions to quickly build a data-driven website. This includes the following:

The automatic verification function is based on the constraints defined in the data model.

By using a field template that has become part of the purpose of a dynamic data item, you can easily change the tag generated for the corresponding field in the gridview and detailsview controls.

For more information, see ASP. NET 4 and new features of Visual Web Developer.

  9. Communication and workflow

Windows communication infrastructure (WCF) enhances message management and provides seamless integration with Windows workflow infrastructure (WF. The improvements provided by WF are embodied in performance, scalability, workflow modeling, and an updated visual designer. For more information, see overview of Basic Features of Windows communication and overview of Basic Features of Windows workflow.

For your security, please only open the URL with reliable source

 

From: http://hi.baidu.com/yandavid/blog/item/7901641e429659f91ad5763a.html

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.