The Microsoft .NET Framework 4.0 is a software framework that can be installed on computers running Microsoft Windows operating systems. Current version is 4.0.30319.1 (4.0) / 12 April 2010; it is supported Windows 98 or later, Windows NT 4.0 or later. Programs written for the .NET Framework execute in a software environment that manages the program's runtime requirements. Also part of the .NET Framework, this runtime environment is known as the Common Language Runtime (CLR) and it is supported by Visual Studio 2010.
C# is a programming language that keeps evolving time by time. If we take a look in 2000, when C# is still a baby, it was just a simple, ordinary, and also for managed code language. And then, C# 2.0 introduced one of the most significant concept, the "Generics" that brought us more type-safety code, performance boost, and also looked more elegant. C# 3.0 is really a big revolution of this language with the most essential thing LINQ (Language Integrated Query). With LINQ, paradigm of C# itself become more like functional programming (not just ordinary imperative paradigm). This language begins it journey of becoming a multi-paradigm language. So, what comes next in C# 4.0 that is going to release with .NET 4.0 and Visual Studio 2010? It is "dynamic programming". Yes, it is a truth. I know that a lot of people (might / will argue) or (are arguing) it. Somebody thinks that the beauty of C# is about its strong-type, how come it become like "dynamic" (somebody calls it irregular style) one? They are disappointed or upset maybe. Somebody might happy and agree with its revolution, it becomes more and more rich. Well, it depends on how you look at it. I don't want to have the argument here.

The .NET Framework 4 introduces an improved security model, APIs, workflow models, inbuilt plug-in, workflow and VS designer for attracting to end-users. Here they added many new features and environment
Introduction:
New features:
- Security Changes in the.NET Framework 4.
- Application Compatibility and Deployment
- Web
- Client - Enhancements in WPF
- Data
- Communications and Workflow

Application Compatibility and Deployment
Security Changes in the.NET Framework 4: They implemented two significant changes in security the code that calls security policy APIs receives a NotSupportedException in addition to compiler warnings at run time, and also they invoked obsolete request permissions.
- Machine-wide security policy
- Security transparency
The .NET Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the.NET Framework. To run old applications with.NET Framework 4, you must compile your application with the target.NET Framework version specified in the properties for your project in Visual Studio, or you can specify the supported runtime with the <supportedRuntime> Element in an application configuration file.
- Diagnostics and Performance
- Garbage Collection
- Code Contracts
- Design-Time-Only Interop Assemblies
- Dynamic Language Runtime
- Memory-Mapped Files
Features in Web:
- Web Forms controls, including a new Chart control.
- Microsoft Ajax, including additional support for client-based Ajax applications in the Microsoft Ajax Library.
- Multi-targeting, including better filtering for features that are not available in the target version of the.NET Framework.
- 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.
- MVC, including new helper methods for views, support for partitioned MVC applications, and asynchronous controllers.
- Deployment, including new tools for automating typical deployment tasks.
- MVC, including new helper methods for views, support for partitioned MVC applications, and asynchronous controllers.
Enhancements in WPF:
- New Controls,
- DataGrid
- Calendar
- DatePicker
- Visual State Manager.
- Touch and Manipulation.
- Graphics and Animations,
- Layout Rounding
- Cached Composition
- Pixel Shader 3 Support
- Easing Functions
- Text,
- New Text Rendering Stack
- Selection and Caret Customization
- Binding,
- XAML Browser Applications
- HTML-XBAP Script Interop
- Full-Trust XBAP Deployment
- WPF and Windows.
- WPF and Silverlight Designer
- Improved Support for Silverlight.
- Support for Multiple Platform Versions.
- Visual Databinding.
- Auto Layout.
- Improved Property Editing.
- The Properties window now enables visually creating and editing Brush resources.
DATA:
- ADO.NET
- Foreign Keys in the Conceptual Model.
- New Methods for N-Tier Application Development.
- EntityDataSource Support for the QueryExtender Control.
- Testability with IObjectSet<T>.
- Direct Execution of Store Commands
- Persistence-Ignorant Objects.
- Lazy Loading of Related Objects.
- Functions in LINQ to Entities Queries.
- OrderBy Improvements in LINQ to Entities.
- Customized Object-Layer Code Generation.
- Model-First Support.
- Complex Type Support.
- Naming Service.
- Improved Model Browser Functionality.
- Entity Designer Extensibility.
- Entity Data Model Documentation.
- Dynamic Data
- Automatic validation that is based on constraints that are defined in the data model.
- 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.
Communications and Workflow:
- WCF
- Configuration Based Activation.
- System.Web.Routing Integration.
- Multiple IIS Site Bindings Support.
- Routing Service.
- Support for WS-Discovery.
- Standard Endpoints.
- Workflow Services.
- Target Framework Attribute.
- WorkFlow
- Workflow Activity Model.
- Rich Composite Activity Options.
- Expanded Built-In Activity Library.
- Explicit Activity Data Model.
- Enhanced Hosting, Persistence, and Tracking Options.
- Easier Ability to Extend WF Designer Experience.
What is DLR in.NET 4.0 framework?
Due to DLR runtime, dynamic languages like ruby, python, JavaScript etc can integrate and run seamlessly with CLR. DLR thus helps to build the best experience for your favorite dynamic language. Your code becomes much cleaner and seamless while integrating with the dynamic languages. Integration with DLR is not limited to dynamic languages. You can also call MS office components in a much cleaner way by using COM interop binder. One of the significant advantages of DLR is that it provides one central and unified subsystem for dynamic language integration.
C# 4.0 Language Innovation
- Dynamically Typed Objects
- Optional and Named Parameters
- Improved COM Interoperability
- Co and Contra variance

What are the advantages and disadvantage of a dynamic keyword?
We all still remember how we talked bad about VB6 (Well I loved the language) variant keyword and we all appreciated how.NET brought in the compile time check feature, well so why are we changing now. Well, bad developers will write bad code with the best programming language, and good developers will fly with the worst programming language. The dynamic keyword is an excellent tool to reduce complexity and it's a curse when not used correctly.
So advantages of Dynamic keyword:
Helps you interop between dynamic languages.
Eliminates bad reflection code and simplifies code complexity.
Improves performance with the method called caching.
Disadvantages:
Will hit performance if used with strongly typed language.
Example: in attached file solution see summary.
10 facts about the Dynamic model: 1. C# 4.0 allows a new static type called "dynamic". 2. Any operation on the object of type dynamic resolve at runtime. 3. The dynamic makes it possible to access the object, without knowing type of the object at compile time. 4. Dynamic types are internally treated as System.Object. 5. At compile time we declare an active type but at run time we get a strongly typed object. 6. Dynamic type gets escaped from compile type checking. But if any error, it caught at runtime. 7. The dynamic model is assumed to perform any task at compile time. 8. Variable of type dynamic compiled into model object. So, after compilation dynamic does not exist. 9. The dynamic model does not support intelli-sense. 10. Object of any language type could be treated as effective type provided they are capable of naturally dispatch them. Dynamic type could be used with 1. Local type 2. Function return type 3. Properties 4. Indexers 5. Class type 6. Function argument 7. Type constraint.
Optional parameters
So advantages of Optional parameters:
Make code more concise.
If no argument sends to parameter default argument is used.
Disadvantages:
Code will not support changes in signature between different assemblies or .dll files, it will need to recompile all dependency files. Five facts about Optional Parameter:
1. Each Optional Parameter has a default value as its part of the definition. 2. If no argument is sent for the Optional Parameter default is being used. 3. Default value of the Optional Parameter must be constant 4. Optional Parameter must define at the end of the any required parameter. 5. Optional Parameter could be applied on Constructor, Method, and Indexer etc.
Improved COM Interoperability
Interoperability with COM objects are our daily code since we still need it and it's impossible to avoid it. Before C# 4.0, it's quite troublesome to write impermeability COM code. Too many "ref" keyword, too many "type.Missing" stuff, and also we need so many casting.The improvements includes:
- Automatic object -> dynamic mapping
- Optional and named parameters
- Indexed properties
- Optional “ref” modifier
- Interop type embedding (“No PIA”)
For instance, now we can write:
Excel.Range range = excel.Cells[1, 1];
//instead of
Excel.Range range = (Excel.Range)excel.Cells[1, 1]
Or
object fileName = "Test.docx";
object missing = System.Reflection.Missing.Value;
doc.SaveAs(fileName);
//Instead of
doc.SaveAs(ref fileName, ref missing, ref missing, ref missing);
Well, it's almost impossible and hard to explain the concept of Covariance and Contravariance in one or two sentences. Eric Lippert posted a complete series of Co & Contra Variance here. Codes mean thousand words
. In short, consider the following code is short explanation of Covariance and Contravariance.
Compiler services
When I first saw this stuff, it made me stunned, and
I like to understand what is this deeper. In C# 4.0, the libraries in the compiler are wrapped in an API in namespace "Microsoft.CSharp", so that we can access the API to do something at the compiler level.

Summary
Download examples: WhatIsNewFrameworkIn4.0.zip (73.82 kb)
What will be next? Microsoft has revealed some details about what will come in the next version of the .NET Framework. A central theme is the introduction of a compiler as a service that enables programmers to embed compilers in their applications. One purpose of this would be to provide scripting engines for applications. What about project on another platforms? We have Mono which is up-to-date implementation of the CLI and the .NET Base Class Library (BCL), and provides additional functionality. It is dual-licensed under free software and proprietary software licenses. Mono is actively being developed by Novell, Inc. It includes support for ASP.NET, ADO.NET, and Windows Forms libraries for a wide range of architectures (including iPhone, Wii and others) and operating systems. It also includes C# and VB.NET compilers. In this article I talked about new features in C# 4.0, thanks for reading and happy coding with .NET Framework and C# language. What do you think about .NET Framework 4.0?
