Tuesday, January 7, 2014

What is new in Dot.Net 4.0

  1. Framework Features
    1. Client Profile (Lite Version of Framework)
      1. The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications. 
      2. Note: - I do not see of much value it just saves around 100 MB of disk space, for me it more overheads to verify on two different platform. I would always suggest to use full version of framework.
    2. In-Process Side-by-Side Execution
      1. This feature enables an application to load and start multiple versions of the .NET Framework in the same process., see In-Process Side-by-Side Execution.
    3. Portable Class Library
      1. Using the Portable Class Library project, you can build portable assemblies that work without modification on the .NET Framework, Silverlight, Windows Phone 7, or Xbox 360 platforms. 
      2. Without the Portable Class Library project, you must target a single platform and then manually rework the class library for other platforms.
    4. CLR Changes
      1. The following sections describe new features and improvements provided by the common language run-time and the base class libraries.
    5. Per app Domain accounting
      1. Starting with the .NET Framework 4, you can get processor usage and memory usage estimates per application domain.
    6. Framework Logging
      1. You can now access the ETW events for diagnostic purposes to improve performance.
    7. Globalization
      1. The .NET Framework 4 supports a minimum of 354 cultures, compared to a minimum of 203 cultures in the .NET Framework 3.5. Many of the new cultures are neutral cultures that were added to complete the parent chain to the root neutral culture. For example, three Inuktitut neutrals were added to the existing cultures Inuktitut (Syllabics, Canada) and Inuktitut (Latin, Canada), as shown in the following table. see What's New in Globalization and Localization.
    8. Garbage Collection
      1. The .NET Framework 4 provides background garbage collection. This feature replaces concurrent garbage collection in previous versions and provides better performance.
      2. In background garbage collection, ephemeral generations (0 and 1) are collected as needed while the collection of generation 2 is in progress.
      3. As with concurrent garbage collection, background garbage collection is performed on a dedicated thread and is applicable only to generation 2 collections.
      4. A collection on ephemeral generations during background garbage collection is known as foreground garbage collection. When foreground garbage collections occur, all managed threads are suspended.
      5. Background garbage collection removes allocation restrictions imposed by concurrent garbage collection, because ephemeral garbage collections can occur during background garbage collection. Background garbage collection is not currently available for server garbage collection. See Fundamentals of Garbage Collection.
  2. Language Features
    1. Code Contracts
      1. Code contracts provide a way to specify preconditions, postconditions, (Ex Contract.Requires(x! = null)) and object invariants in your code. Preconditions are requirements that must be met when entering a method or property. Postconditions describe expectations at the time the method or property code exits. Object invariants describe the expected state for a class that is in a good state. See Code Contracts.
  3. Design-Time-Only Interop Assemblies (Embed type information)
    1. You no longer have to ship primary interop assemblies (PIAs) to deploy applications that interoperate with COM objects. In the .NET Framework 4, compilers can embed type information from interop assemblies, selecting only the types that an application (for example, an add-in) actually uses.
  4. Dynamic Language Runtime
    1. Dynamic languages can identify the type of an object at run time, whereas in statically typed languages such as C# and Visual Basic (when you use Option Explicit On) you must specify object types at design time. Examples of dynamic languages are Lisp, Smalltalk, JavaScript, PHP, Ruby, Python, ColdFusion, Lua, Cobra, and Groovy. see Dynamic Language Runtime Overview.
  5. Covariance and Contravariance
    1. Several generic interfaces and delegates now support covariance and contravariance (assigning base to derived type reference). see Covariance and Contravariance in Generics.
  6. BigInteger and Complex Numbers
    1. The new System.Numerics.BigInteger structure is an arbitrary-precision integer data type that supports all the standard integer operations, including bit manipulation.
    2. The new System.Numerics.Complex structure represents a complex number that supports arithmetic and trigonometric operations with complex numbers.
  7. Tuples
    1. tuple is a data structure that has a specific number and sequence of elements. See example belwo
    2.  The .NET Framework 4 provides the System.Tuple class for creating tuple objects that contain structured data.
    3.  It also provides generic tuple classes to support tuples that have from one to eight components (that is, singletons through octuples).
    4.  To support tuple objects that have nine or more components, there is a generic tuple class with seven type parameters and an eighth parameter of any tuple type. 
  8. File System Enumeration Improvements
    1. Starting with the .NET Framework version 4, you can enumerate directories and files by using methods that return an enumerable collection of strings of their names. You can also use methods that return an enumerable collection of DirectoryInfoFileInfo, or FileSystemInfo objects. In previous versions of the .NET Framework, you could only obtain arrays of these collections. Enumerable collections provide better performance than arrays. See How to: Enumerate Directories and Files.
  9. Memory-Mapped Files
    1. memory-mapped files. contains the contents of a file in virtual memory. This mapping between a file and memory space enables an application, including multiple processes, to modify the file by reading and writing directly to the memory.
    2. Starting with the .NET Framework version 4, you can use managed code to access memory-mapped files in the same way that native Win32 functions access memory-mapped files,
  10. 64-Bit Operating Systems and Processes
    1. You can identify 64-bit operating systems and processes with the Environment.Is64BitOperatingSystem and Environment.Is64BitProcess properties.
    2. You can specify a 32-bit or 64-bit view of the registry with the Microsoft.Win32.RegistryView enumeration when you open base keys.
  11. Profiling
    1. In the .NET Framework 4.0, you can attach profilers to a running process at any point, perform the requested profiling tasks, and then detach. For more information, see the [IClrProfiling::AttachProfiler]IClrProfiling Interface::AttachProfiler Method method.
  12. Corrupted State Exceptions
    1. The CLR no longer delivers corrupted state exceptions that occur in the operating system to be handled by managed code, unless you apply the HandleProcessCorruptedStateExceptionsAttribute attribute to the method that handles the corrupted state exception.
    2. Alternatively, you can add the following setting to an application's configuration file: legacyCorruptedStateExceptionsPolicy=true
  13. Named and Optional Parameters
    1. C# didn't have Optional Parameters that VB.NET had for a long time. One who is coming from VB or VB.NET will definitely miss this feature. Lets start with Optional Parameter first. See the code :
  14. API Improvements 
    1. The following list describes additional new capabilities, improvements, and conveniences. Several of these are based on customer suggestions.
    2. To support culture-sensitive formatting, the System.TimeSpan structure includes new overloads of the ToString, Parse, and TryParse methods, as well as new ParseExact and TryParseExact methods.
    3. The new String.IsNullOrWhiteSpace method indicates whether a string is null, empty, or consists only of white-space characters. New overloads have been added to the String.Concat and String.Join methods that concatenate members of System.Collections.Generic.IEnumerable(Of T) collections.
    4. The String.Concat method lets you concatenate each element in an enumerable collection without first converting the elements to strings.
    5. Two new convenience methods are available: StringBuilder.Clear and Stopwatch.Restart.
    6. The new Enum.HasFlag method determines whether one or more bit fields or flags are set in an enumeration value. The Enum.TryParse method returns a Boolean value that indicates whether a string or integer value could be successfully parsed.
    7. The System.Environment.SpecialFolder enumeration contains several new folders.
    8. You can now easily copy one stream into another with the CopyTo method in classes that inherit from the System.IO.Stream class.
    9. New Path.Combine method overloads enable you to combine file paths.
    10. The new System.IObservable(Of T) and System.IObserver(Of T) interfaces provide a generalized mechanism for push-based notifications.
    11. The System.IntPtr and System.UIntPtr classes now include support for the addition and subtraction operators.
    12. You can now enable lazy initialization for any custom type by wrapping the type inside a System.Lazy(Of T) class.
    13. The new System.Collections.Generic.SortedSet(Of T) class provides a self-balancing tree that maintains data in sorted order after insertions, deletions, and searches. This class implements the new System.Collections.Generic.ISet(Of T) interface.
    14. The compression algorithms for the System.IO.Compression.DeflateStream and System.IO.Compression.GZipStream classes have improved so that data that is already compressed is no longer inflated. Also, the 4-gigabyte size restriction for compressing streams has been removed.
    15. The new Monitor.Enter(Object, Boolean) method overload takes a Boolean reference and atomically sets it to true only if the monitor is successfully entered.
    16. You can use the Thread.Yield method to have the calling thread yield execution to another thread that is ready to run on the current processor.
    17. The System.Guid structure now contains the TryParse and TryParseExact methods.
    18. The new Microsoft.Win32.RegistryOptions enumeration lets you specify a volatile registry key that does not persist after the computer restarts.
    19. Registry keys are no longer restricted to a maximum length of 255 characters.
  15. New Features and Frameworks
    1. Managed Extensibility Framework
    2. The Managed Extensibility Framework (MEF) is a new library in the .NET Framework 4 that helps you build extensible and composable applications. MEF enables you to specify points where an application can be extended, to expose services to offer to other extensible applications and to create parts for consumption by extensible applications.
    3. It also enables easy discoverability of available parts based on metadata, without the need to load the assemblies for the parts. For more information, see Managed Extensibility Framework Overview and Managed Extensibility Framework. For a list of the MEF types, see the System.ComponentModel.Composition namespace.
  16. Parallel Computing
    1. The .NET Framework 4 introduces a new programming model for writing multithreaded and asynchronous code that greatly simplifies the work of application and library developers.
    2. The new model enables developers to write efficient, fine-grained, and scalable parallel code in a natural idiom without having to work directly with threads or the thread pool.
    3. The new System.Threading.Tasks namespace and other related types support this new model.
    4. Parallel LINQ (PLINQ), which is a parallel implementation of LINQ to Objects, enables similar functionality through declarative syntax. For more information, see Parallel Programming in the .NET Framework.
  17. Networking Changes
    1. Networking improvements include the following:
    2. ·         Security improvements for Windows authentication in several classes, including System.Net.HttpWebRequestSystem.Net.HttpListenerSystem.Net.Mail.SmtpClientSystem.Net.Security.SslStream, and System.Net.Security.NegotiateStream. Extended protection is available for applications on Windows 7 and Windows Server 2008 R2. For more information, see Integrated Windows Authentication with Extended Protection.
    3. ·         Support for Network Address Translation (NAT) traversal using IPv6 and Teredo. For more information, see NAT Traversal using IPv6 and Teredo.
    4. ·         New networking performance counters that provide information about HttpWebRequest objects. For more information, see Networking Performance Counters.
    5. ·         In the System.Net.HttpWebRequest class, support for using large byte range headers (64-bit ranges) with new overloads for the AddRange method. New properties on the System.Net.HttpWebRequest class allow an application to set many HTTP headers. You can use the Host property to set the Host header value in an HTTP request that is independent from the request URI.
    6. ·         Secure Sockets Layer (SSL) support for the System.Net.Mail.SmtpClient and related classes.
    7. ·         Improved support for mail headers in the System.Net.Mail.MailMessage class.
    8. ·         Support for a null cipher for use in encryption. You can specify the encryption policy by using the System.Net.ServicePointManager class and the EncryptionPolicy property. Constructors for the System.Net.Security.SslStream class now take a System.Net.Security.EncryptionPolicy class as a parameter.
    9. ·         Credentials for password-based authentication schemes such as basic, digest, NTLM, and Kerberos authentication in the System.Net.NetworkCredential class. To improve security, passwords may now be treated as System.Security.SecureString instances rather than System.String instances.
    10. ·         Ability to specify how a URI with percent-encoded values is converted and normalized in the System.Uri and System.Net.HttpListener classes. For more information, see the System.Net.Configuration.HttpListenerElementSystem.Configuration.SchemeSettingElementSystem.Configuration.SchemeSettingElementCollection, and System.Configuration.UriSection classes.
  18. ASP.Net Changes 
    1. ASP.NET version 4 introduces new features in the following areas:
    2. Core services, including a new API that lets you extend caching, support for compression for session-state data, and a new application preload manager (autostart feature).
    3. Web Forms, including more integrated support for ASP.NET routing, enhanced support for Web standards, updated browser support, new features for data controls, and new features for view state management.
    4. Web Forms controls, including a new Chart control.
    5. MVC, including new helper methods for views, support for partitioned MVC applications, and asynchronous controllers.
    6. Dynamic Data, including support for existing Web applications, support for many-to-many relationships and inheritance, new field templates and attributes, and enhanced data filtering.
    7. Microsoft Ajax, including additional support for client-based Ajax applications in the Microsoft Ajax Library.
    8. Visual Web Developer, including improved IntelliSense for JScript, new auto-complete snippets for HTML and ASP.NET markup, and enhanced CSS compatibility.
    9. Deployment, including new tools for automating typical deployment tasks.
    10. Multi-targeting, including better filtering for features that are not available in the target version of the .NET Framework.
    11. For more information about these features, see What's New in ASP.NET 4 and Visual Web Developer.
  19. WPF Changes
    1. New controls, including CalendarDataGrid, and DatePicker.
    2. VisualStateManager supports changing states of controls.
    3. Touch and Manipulation enables you to create applications that receive input from multiple touches simultaneously on Windows 7.
    4. Graphics and animation supports layout rounding, Pixel Shader version 3.0, cached composition, and easing functions.
    5. Text has improved text rendering and supports customizing the caret color and selection color in text boxes.
    6. Binding is supported on the Command property of an InputBinding, dynamic objects, and the Text property.
    7. XAML browser applications (XBAPs) support communication with the Web page and support full-trust deployment.
    8. New types in the System.Windows.Shell namespace enable you to communicate with the Windows 7 taskbar and pass data to the Windows shell.
    9. The WPF and Silverlight Designer in Visual Studio 2010 has various designer improvements to help create WPF or Silverlight applications.
    10. For more information, see What's New in WPF Version 4.
  20. Data Access Changes
    1. ADO.NET
      1. ADO.NET provides new features for the Entity Framework, including persistence-ignorant objects, functions in LINQ queries, and customized object layer code generation. For more information, see What's New in ADO.NET.
    2. Dynamic Data
      1. For ASP.NET 4, Dynamic Data has been enhanced to give you even more power for quickly building data-driven Web sites. This includes the following:
      2. Automatic validation that is based on constraints that are defined in the data model.
      3. The ability to easily change the markup that is generated for fields in the GridView and DetailsView controls by using field templates that are part of a Dynamic Data project.
      4. For more information, see What's New in ASP.NET 4 and Visual Web Developer.
    3. WCF Data Services
      1. ADO.NET Data Service has been renamed to WCF Data Services, and has the following new features
      2. Data binding.
      3. Counting entities in an entity set.
      4. Server-driven paging.
      5. Query projections.
      6. Custom data service providers.
      7. Streaming of binary resources.
      8. For more information, see What's New in WCF Data Services.
  21. WCF Changes 
    1. Core WCF Changes
    2. Windows Communication Foundation (WCF) provides the following improvements:
    3. Configuration-based activation: Removes the requirement for having an .svc file.
    4. System.Web.Routing integration: Gives you more control over your service's URL by allowing the use of extensionless URLs.
    5. · Multiple IIS site bindings support: Allows you to have multiple base addresses with the same protocol on the same Web site.
    6. · Routing Service: Allows you to route messages based on content.
    7. · Support for WS-Discovery: Allows you to create and search for discoverable services.
    8. · Standard endpoints: Predefined endpoints that allow you to specify only certain properties.
    9. · Workflow services: Integrates WCF and WF by providing activities to send and receive messages, the ability to correlate messages based on content, and a workflow service host.
  22. New WCF REST features:
    1. Web HTTP caching: Allows caching of Web HTTP service responses.
    2. Web HTTP formats support: Allows you to dynamically determine the best format for a service operation to respond in.
    3. Web HTTP services help page: Provides an automatic help page for Web HTTP services, similar to the WCF service help page.
    4. Web HTTP error handling: Allows Web HTTP Services to return error information in the same format as the operation.
    5. Web HTTP cross-domain JavaScript support: Allows use of JSON Padding (JSONP).
    6. Simplified configuration: Reduces the amount of configuration a service requires
    7. For more information, see What's New in Windows Communication Foundation
  23. Windows Workflow Foundation
    1. Improved workflow activity model: The Activity class provides the base abstraction of workflow behavior.
    2. Rich composite activity options: Workflows benefit from new flow-control activities that model traditional flow-control structures, such as FlowchartTryCatch, and Switch(Of T).
    3. Expanded built-in activity library: New features of the activity library include new flow-control activities, activities for manipulating member data, and activities for controlling transactions.
    4. Explicit activity data model: New options for storing or moving data include variable and directional arguments.
    5. Enhanced hosting, persistence, and tracking options: Hosting enhancements include more options for running workflows, explicit persistence using the Persistactivity, persisting without unloading, preventing persistence by using no-persist zones, using ambient transactions from the host, recording tracking information to the event log, and resuming pending workflows by using a Bookmark object.
    6. Easier ability to extend the WF Designer: The new WF Designer is built on Windows Presentation Foundation (WPF) and provides an easier model to use when rehosting the WF Designer outside of Visual Studio.
    7. For more information, see What's New in Windows Workflow Foundation.
  24. Security Changes in the .NET Framework 4.
    1. TODO
  25. New Types and Members in the .NET Framework 4.
    1. TODO

1 comment: