WHAT IS IN STORE FOR US IN .NET FRAMEWORK 3.5? 2.0

quiverlickforkSoftware and s/w Development

Nov 2, 2013 (4 years and 11 days ago)

123 views

2.1 Overview
WHAT IS IN STORE FOR US IN
.NET FRAMEWORK 3.5?
2.0
02
This chapter details the enhancments and new features provided in .NET Framework 3.5.
.NET Framework 3.5 includes:
∙ Performance enhancements at the Common Language Runtime (CLR) level
∙ Language-level enhancements
∙ Improvements to existing technologies such as:
∙ Windows Presentation Foundation (WPF)
∙ Windows Communication Foundation (WCF)
∙ Windows Workflow Foundation (WF)
∙ Windows CardSpace (WCS)
To build applications using .NET framework 3.5, Microsoft has also released the
newer version of its Integrated Development Environment (IDE). Named Visual Studio
2008 (VS 2008), this newer version incorporates significant feature and performance
enhancements that are described in this handbook. These help make developers
more productive.
.NET Framework 3.5 comprises of .NET Framework 1.1, 2.0 and 3.0, and additional
libraries that provide 3.5 functionalities. This handbook deals with the features of
.NET Framework 3.0 and 3.5. For details on .NET Framework 2.0, please refer our
book – 101 reasons to go for .NET Framework 2.0 (
http://www.infosys.com/research/
publications/101-reasons-to-go-for-dotnet/default.asp).
The table below provides information on different .NET versions and their major
components.
03
Table 1:.NET Versions and their Components
04
∙ Table 1 provides version details of only C# and VB.NET languages. .NET does
support various languages such as C++ and FoxPro. In fact, Dynamic Language
Runtime (DLR) features have now been integrated with CLR to help scripting
languages implementors with respect to a shared dynamic type set, faster code
generation, and so on
∙ Integration of DLR with CLR is part of Silverlight initiative. Silverlight – earlier
code-named WPF/E (WPF/Everywhere) – is a cross-browser and cross-platform
CLR. With the addition of DLR, it supports various scripting languages such as
Python and JavaScript and will support Ruby and VBx (Dynamic VB.NET) in the
future
∙ Since Microsoft has stopped development on J# (Microsoft version of Java
programming for the .NET Framework), it is not included in VS 2008
∙ VS 2008 has a multi-targeting feature using which applications can be built for
.NET Framework 2.0 or 3.0 or 3.5 versions
∙.NET Framework 1.0 mainstream support ended in July 2007 and the extended
support is ending in year Q3 2009
Figure 1: Additive Versions of .NET Framework (Source: MS Documentation)
The following figure is a pictorial representation of various versions of the .NET
Framework:
05
As can be seen from the above picture, .NET Framework 3.0 and .NET Framework
3.5 are fairly independent in their feature set. All the three Framework versions
share the same CLR, which has not changed from .NET Framework 2.0 onwards.
Hence, .NET Framework 2.0 applications can be directly upgraded to .NET Framework
3.5.
Refer to
http://www.danielmoth.com/Blog/2007/06/net-framework-35.html.NET
Framework 3.5 has two elements – green bits and the red bits.
The red bits are framework bits that exist in .NET Framework versions 2.0 and 3.0.
.NET Framework 3.5 includes updates for these two existing frameworks. These
updates are not merely a bunch of new features or changes, but a service pack
predominantly containing bug fixes and performance improvments.
The green bits are brand new assemblies with new framework classes in them.
These simply add to the .NET Framework without changing existing assemblies and
without changing the CLR engine.
.NET Framework 3.5 has the following new assemblies:
∙ System.Data.Linq.dll – The implementation for LINQ to SQL
∙ System.Xml.Linq.dll – The implementation for LINQ to XML
∙ System.AddIn.dll, System.AddIn.Contract.dll – New AddIn (Plug-in) model.
∙ System.Net.dll – Peer-to-Peer APIs.
∙ System.Management.Instrumentation.dll –
Windows Management Instrumentation
(WMI) 2.0 managed provider (Combined with System.Management namespace in
System.Core.dll)
∙ System.WorkflowServices.dll and System.ServiceModel.Web.dll – WF and WCF
enhancements
∙ System.Web.Extensions.dll – The implementation for ASP.NET AJAX extensions
plus also the implementation of client application services and three ASP.NET 3.5
controls.
∙ System.Data.DataSetExtensions.dll – The implementation of LINQ to DataSet
∙ System.Windows.Presentation.dll – WPF support for the System.AddIn
∙ System.VisualC.STLCLR.dll – STL development in the managed world.
06
.NET Framework 3.5 contains the following significant features:
∙ New language features are introduced in C# 3.0 and VB.NET 9.0
∙ Language Integrated Query (LINQ) introduced to exploit the expressive power of
query languages from object-oriented programming of .NET
∙ ASP.NET performance improvements
∙ Garbage collection enhancements
∙ New additions to Base Class Libraries
∙ Efficient Inter-Process and collaboration communication facilities
∙ Dynamic Code Generation in Partial Trust environment
∙ Events and Tracing improvements
∙ ADO.NET enhancements
∙ WPF enhancements
∙ WCF enhancements
∙ WF enhancements – Integration of WCF with WF technology
∙ Windows Forms Application enhancements
These features will be explained in detail in the following sections.
2.2 General Features
In the following sections, we will discuss generic language, feature and performance
enhancements in .NET Framework 3.0 and 3.5.
2.2.1 Language Features
NET Framework 2.0 introduced a set of useful features such as generics, partial
types, anonymous delegates, and so on, to help improve developers’ productivity.
.NET Framework 3.5 introduces the following new language features mainly to support
language integrated query (LINQ). However, these features can also be used without
using LINQ. These features enable the writing of more compact and maintainable
code.
07
2.2.1.1 Auto-implemented Properties
Auto-implemented properties make property declaration more concise when no
additional logic is required in the property getters and setters. Attributes are not
permitted in the auto-implemented properties. If attributes are required, then normal
properties should be created.
2.2.1.2 Object Initializer
While creating an instance of a class, developers create the object and set the
properties in separate statements. An object initializer makes the code more concise
since a single statement can perform both these tasks. VS 2008 provides appropriate
IntelliSense to work with object initializers.
2.2.1.3 Collection Initializer
Similar to the object initializer, .NET Framework 3.5 provides an easier method to
initialize collection objects that prevents the writing of multiple “Add” statements.
2.2.1.4 Extension Methods
.NET Framework 3.5 allows developers to add methods, i.e., extend existing class
behavior using Extension Methods. Prior to .NET Framework 3.5, an existing type
was extended using one of the following approaches:
∙ Adding the extended functionality to the source code
∙ Re-implementing the functionality from scratch
∙ Using inheritance to inherit the functionality contained within one type into a new
derived type (Note: Not all types are inheritable)
None of these approaches are useful while extending third-party types. Usually, third
party libraries do not provide the source code, and types in them are marked as
“sealed” to stop classes that are outside of them. It means that this extension can be
done without recompiling or sub-classing the original type.
Compiler automatically creates backing fields for storage of the property values.
This does away with the need to pick up names for numerous variables that are
created only to hold the property value.
08
LINQ primarily depends on this feature because query expressions are implemented
as extension members to the IEnumerable type in .NETFramework 3.5.
2.2.1.5 Implicit Local Variable Type Inference
In the previous .NET Framework versions, developers were forced to declare the type
of the variable as it was mandatory for compilers to know the types. The variable
could be declared as an object type if the accuracy of the variable type was not a
concern. However, internal and external casting (Boxing and Unboxing) were required
when such object type variables were used.
In .NET Framework 3.5, developers are allowed to declare the variables without
mentioning their types by using the keyword var. The compiler infers the type through
its initialized values.
An initializer expression is mandatory in the same line where ‘var’ is used. Additionally,
such variables are local to methods and cannot be sent as parameters or returned
from the method call.
2.2.1.6 Anonymous Types
Anonymous types must only be used to group data items. They should not be used
in cases where name or method overriding is required and should exist in the scope
of the current method.
Anonymous methods introduced in .NET Framework 2.0 allow developers to create
nameless methods. This feature is useful for creating event handlers, since they do
not require explicit functions with names. .NET Framework 3.5 allows developers to
create types without names. Anonymous types can be used to avoid type proliferation.
2.2.1.7 Query Expression
A Query expression is the basic constituent of LINQ, as it provides a path for the
query to be expressed using .NET class notations.
09
2.2.1.8 Lambda Expression
A Lambda expression is the natural evolution of C# 2.0 anonymous methods. It
provides a compact syntax to briefly express the query using .NET notations.
A Query expression is internally built using the Lambda expression. Developers can
opt either for Lambda or Query expression.
2.2.1.9 Partial Methods
.NET Framework 2.0 introduced the concept of partial types, which distributes the
characteristics and behaviors of types across files within an assembly boundary.
Although .NET Framework 2.0 allows the type to be partial, it does not allow a
method to be partially distributed in that type.
.NET 3.5 introduces partial methods which must be declared within partial classes.
This means that the declaration and implementation of a method can be written in
different files. This approach provides developers flexibility in implementing the
method. There may be some scenarios where implementation of a method may be
ideal but not mandatory. Partial methods are useful in such scenarios. Partial methods
are private and should always return void. No attribute or modifier can be applied at
this partial method level.
The developer is free to provide an implementation of the method, if required. If an
implementation is not provided while building the application, the compiler will remove
the definition of the method and all call sites where the method call is used. The
method does not appear in Intermediate Language (IL) or final code and hence there is
no overhead.
2.2.1.10 Support for Nullable Type
The Nullable type introduced in .NET Framework 2.0 declares a variable to contain a
null object, which was earlier available only in C#. Now VB.NET 9.0 also supports
10
Nullable types. The benefits will be seen in database interactions where the data can
be undefined (no data). This helps variables of types like Boolean and integer to
contain null values, which is otherwise not a valid value for these types.
2.2.1.11 Support for Covariance and Contravariance Delegates
Covariance and Contravariance delegates were available only in C# in .NET Framework
2.0. Now, VB.NET 9.0 also supports Covariance and Contravariance delegates in its
repertoire.
∙ Covariance and Contravariance provide flexibility when matching method signatures
with delegate types. Covariance allows the delegate method to be invoked by
using a more derived type than what is defined in the delegate’s signature.
Contravariance allows invoking a delegate method with parameter types that are
less derived than as defined in the delegate’s signature
∙ In .NET Framework 3.5, changes are not only made to primary .NET languages
such as C# and VB.NET but also on Visual C++
∙ Visual C++ 2008 includes a STL/CLR library that is a packaging of the
standard template library (STL) and a subset of the standard C++ library for
use with C++ and the .NET Framework CLR. With STL/CLR, STL elements
such as containers, iterators and algorithms can be used in a managed
environment
∙ Many new classes and methods have been added in MFC library in order to
support features in Windows Vista operating system
∙ A marshalling library has been introduced in order to provide an optimized way
to marshal data between native and managed environments
∙ Many improvements in performance (for example, reducing total build time)
and productivity (for example, managed incremental build support) have been
achieved in the Visual C++ compiler and linker
∙ Future version of VS may support F# programming language (one of Microsoft’s
research projects) – a functional programming language that will be useful in
financial, scientific and technical computing domains
11
2.2.2 Language Integrated Query (LINQ) Support
LINQ support is one of the significant general features of .NET Framework 3.5. While
managed languages are used to develop components for any layer of distributed
application architecture, the data access layer still depends on the logic written
using specific query languages such as SQL.
.NET Framework (as early as version 1.0) provides managed wrappers to communicate
with back-end databases through ADO.NET. ADO.NET in turn understands and
executes the queries written in SQL. Basically, it communicates with the database
using a specific language and converts the data into specific .NET types such as
DataSet, DataReader and so on. This clearly implies that SQL programming is required
to perform create, read, update, and delete (CRUD) operations on the database side.
The problem with SQL language is that it is not as flexible as object-oriented
programming language, though it is very expressive in nature. Hence, during application
development, a developer has to learn two programming languages of different natures.
LINQ brings the expressiveness of query languages to the managed languages. LINQ
is not hamstrung by tight coupling with any of the query languages. But this flexible
accessibility does not stop only at the backend database. In fact, .NET Framework
3.5 also supports the following, apart from its (LINQ’s) support to SQL, which enables
direct querying over database tables and view, through managed languages:
∙ LINQ to Objects API: Enables querying of data that is available within collection
objects such as an array and hash tables
∙ LINQ to Entity: Enables querying the entity model, which is based on EDM of
ADO.NET
∙ LINQ over XML: Enables querying XML fragments and files through .NET notations
∙ LINQ to the SQL Designer: Enables easy creation of entity classes for back-end
data objects through the visual designer, wizards or templates of VS 2008
The Object Relational Mapping (ORM) provides the ability to work with the entity
model instead of working with the physical data model. It mitigates issues caused by
the complexity of dealing with back-end models and modifications made to the back-
end models. The ORM is, in general, achieved through a third party or external vendor
12
software, as there was no inherent support for ORM from MS for .NET framework
application development till the introduction of .NET Framework 3.5.
Earlier, MS had planned to tackle ORM through ‘ObjectSpaces’ in .NET Framework
2.0. For certain reasons, ObjectSpaces was shelved. However, shades of
‘ObjectSpaces’ will be seen in future versions of .NET Framework in the form of
Entity Data Model of ADO.NET. The LINQ technology introduced in .NET Framework
3.5 partially addresses ORM. This technology allows developers to blend the
expressive power of query languages – such as SQL and XQuery – into managed
languages – such as C# and VB.NET. As a result, application developers can use
familiar object-oriented programming notations to query data. LINQ works with
both relational database and XML documents. It also works with SQL Entity Data
Model (EDM) and SQL Designer. LINQ is designed to provide a one-to-one mapping
with SQL. Please see ASP.NET Enhancements for more details.
2.2.3 ASP.NET Enhancements
In the following section, we will look at specific enhancements that have happened
in the web development space.
2.2.3.1 ASP.NET AJAX
AJAX extensions are supported in .NET Framework 2.0 as external add-ins and not in
an integrated manner. However, in .NET Framework 3.5, ASP.NET integrates AJAX
extensions into it. ASP.NET AJAX consists of the following three components:
∙ ASP.NET extensions: Makes AJAX development look similar to traditional ASP.NET
development
∙ Library of client-side script code: Provides common client-side functionalities that
work across all browsers
∙ Control toolkit: Provides developers a library of AJAX controls to use as-is or
customize according to their needs
ASP.NET in .NET Framework 3.5, provides better server-centric AJAX development
with a set of new server controls and APIs. It also supports client-centric AJAX
13
development with a new client library called the Microsoft AJAX library. The Microsoft
AJAX library supports the development of browser-independent and client-centric
applications that are based on the object-oriented paradigm.
ASP.NET now supports AJAX extender controls that enhance client-side capabilities
of standard web server controls. In ASP.NET Web applications, these extender
controls (either as part of ASP.NET AJAX Control Toolkit or customized) can be
bound to standard web server controls – such as Textbox, Button, and Panel – to
provide a better and richer user experience.
ASP.NET now supports seamless usage of WCF-based web services from web pages
using Microsoft AJAX library. Consuming WCF web services from within the client-
side is an important and useful feature; considering the fact that server-side application
services – such as forms-based authentication, roles management, and profiles
management – are exposed as web services in .NET Framework 3.5. These services
can be effectively used across multiple web applications in an enterprise.
These web services (Membership, Roles and Profiles management) support both
SOAP and JSON (JavaScript Object Notation) data exchange formats. While SOAP
message format caters to any SOAP compliant clients such as Windows Forms,
WPF, as well as applications developed using frameworks other than .NET, the JSON
data exchange format caters to AJAX scenarios.
JSON is a standardized data exchange format based on open and text-based
standards, and should be effectively used in AJAX-based scenarios. For more
details, please see the relevant link for JSON in the References section.
2.2.3.2 Silverlight
ASP.NET also provides better support for Silverlight – Microsoft’s new platform
for creating Rich Internet Applications (RIA). More details on Silverlight are provided
in the section WINDOWS PRESENTATION FOUNDATION (WPF).
14
2.2.3.3 Traditional ASPX model
ASP.NET also provides new server side controls such as:
∙ ListView Control: A data-bound control designed to provide great formatting flexibility
with cascading style sheet (CSS) for website designers. From a data binding and
events perspective, ListView should seem very familiar to ASP.NET developers
∙ DataPager Control: Provides navigation through pagination, and is an ideal
companion of the ListView Control
∙ LinqDataSource Control: Allows a declarative usage of LINQ by using the data
source control design pattern (introduced in VS 2005). With the added designer
support, it becomes very easy to bind data against LINQ expressions
Though the ASP.NET model with its code-behind-page concept is akin to Model
View Controller (MVC) pattern, complex applications require implementing the MVC
pattern by developing specialized controller and view components. To improve
development productivity, Microsoft has planned to release ASP.NET MVC pattern
framework. It will be shipped as a fully supported ASP.NET feature in the first half
of 2008. The MVC framework will work with VS 2008. The MVC framework itself
will exist in a separate assembly to begin with, and later be built-in to .NET
Framework 3.5 SP1. For more details, please see Scott Guthrie’s blog:
http://
weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx
NET Framework 3.5 is tightly integrated with IIS 7.0. Various ASP.NET services like
forms authentication and caching can be used for all content types, and not just for
ASP.NET web pages. It is made possible because ASP.NET and the web server now
use the same request pipeline. This unified request processing pipeline allows the
developer to create managed HTTP modules in ASP.NET that can work with all
requests in IIS.
2.2.4 Improved Asynchronous Model in .NET 3.5
There are two important mechanisms – Asynchronous I/O and IO completion port –
that are implemented in Windows for scaling up server applications.
15
Asynchronous I/O is a mechanism through which a calling thread can submit an I/O
request and return before the submitted request gets served by the kernel. The
calling thread can utilize the returned control for additional processing before it goes
to sleep and waits for the submitted IO request to be completed. There are two main
ways by which the calling thread identifies the status and result of the submitted
asynchronous I/O request – EventObject and IO completion port.
The EventObject can be set into an OVERLAPPED structure that can be passed to a
ReadFile or WriteFile function which in turn is called on an I/O object, opened with
FILE_FLAG_OVERLAPPED.
The other mechanism, IO Completion Port, is a kernel object that can be associated
with a number of I/O objects like file, pipe, or a socket. When an asynchronous
operation is started on I/O objects that have been associated with the IO completion
port, the calling thread returns immediately. On completing the submitted I/O request,
the kernel dispatches the completion packet to the queue associated with the IO
completion port.
The Socket class of System.Net.Sockets provides virtually all the functionality of
the Windows WinSock Win32 API and uses Windows I/O Completion ports for
asynchronous I/O operation completion. This allows applications to easily scale to
a large number of open sockets. .NET Framework implements the ThreadPool class
that provides completion threads to read completion ports and complete asynchronous
I/O operations.
In .NET Framework 3.5, a new type – SocketAsyncEventArgs – has been introduced
to wrap the context of the operation. This object can be created in the application
and hence can be reused
Enhancements related to Asynchronous I/O operations – EventObject and IO
completion Port – can be realized even if the existing application runs in .NET
Framework 3.5 runtime
With .NET Framework 3.5, the CLR can now manage a large number of overlapped
objects simultaneously. It is now possible to have 60,000 or more connected
sockets while maintaining a pending asynchronous receive I/O operation on each
socket.
16
In previous versions of .NET Framework, socket classes used the familiar Begin/End
pattern-based asynchronous programming model. Though this is a good model, the
object IAsyncResult created by each asynchronous operation may cause a memory
overhead. This happens as this object cannot be reused or shared across multiple
asynchronous socket calls – the IAsyncResult object is actually wrapping the context
of the operation, and application does not create it.
In .NET Framework 3.5, a new type – SocketAsyncEventArgs – has been introduced
to wrap the context of the operation. This object can be created in the application
and hence can be reused
Enhancements related to Asynchronous I/O operations – EventObject and IO
completion Port – can be realized even if the existing application runs in .NET
Framework 3.5 runtime
2.2.5 Performance-related Improvements
.NET Framework 3.5 focuses on improving the performance of crucial features like
Garbage Collection (faster garbage collection), Native Assembly creation using NGen
(smarter NGen which requires smaller working set RAM), Thread Pool and Reader/
Writer Locks (more light-weight now) on the objects.
It is important to know that Microsoft has re-architected the thread pool component
of Windows Vista and Windows Server 2008. The new thread pool component
addresses a number of limitations of the legacy thread pool. For example, it allows
the creation of multiple thread pools per process. Due to changes caused by the
implementation of this new thread pool component, Microsoft has also released
new thread pool APIs (though legacy APIs are untouched in order to support the
legacy applications) that help developers write correct code
.NET Framework 3.5 has introduced a new class – ReaderWriterLockSlim –
that provides better performance than ReaderWriterLock. The performance of
ReaderWriterLockSlim is comparable with the lock statement in C# (SyncLock
in VB)
17
2.2.5.1 High Performant HashSet
.NET Framework 3.5 introduces a collection object known as HashSet. This
collection object contains a set of unordered but unique elements and supports a set
of related operations such as UnionWith, IntersectWith, ExceptWith, and more.
It is also claimed to be highly performant.
2.2.5.2 Parallel Programming Extensions to .NET Framework 3.5
Multi-core processors have arrived in the mainstream of computing as heat dissipation
from a single processor is very high. However, most applications today are designed
for single processor environments.
Parallel programming extensions make it easier for developers to take advantage of
multi-core processors that are available in the market. They run as extensions to
.NET Framework 3.5. A CTP version was released recently. More details can be
obtained from Somasegar’s blog:
http://blogs.msdn.com/somasegar/archive/2007/
11/29/parallel-extensions-to-the-net-fx-ctp.aspx.
The Parallel Framework contains two main libraries – Parallel LINQ Library (PLINQ)
and Task Parallel Library (TPL). Parallel LINQ enables the LINQ operations to be
parallel while Task Parallel Library optimizes and provides mechanisms to easily
write programs that can exploit the multi-core processor systems that are now
widespread.
2.2.5.3 Garbage Collection Improvements
Garbage collection occurs during an application’s execution and is based on the
memory requirements of the application. If garbage collection occurs at a critical
time, it may impact the application performance. .NET Framework 3.5 provides a
way to adjust the latency of the garbage collector. It introduces a property –
LatencyMode – in GCSettings class that can be set to an appropriate value such
as LowLatency or HighLatency depending on the application needs. In LowLatency
mode, the garbage collector becomes less intrusive as it tends to function
conservatively in reclaiming objects.
.NET Framework 3.5 also provides a mechanism to adjust the behavior of garbage
collection even during a forced collection. Garbage collection can be forced through
Collect method of GC class (available even in previous versions of .NET Framework).
18
The current version of .NET Framework provides a new overload method that specifies
whether or not the current time is optimal to reclaim objects before object collection.
2.2.6 New Additions to Base Class Library
In this section we will explore the key additions to the base class library.
2.2.6.1 FIPS-certified Cryptographic Algorithms
The National Security Agency (NSA) has defined a category of Suite B algorithms to
enable secure encryption, hashing, signing and sensitive key exchange processes.
For widespread interoperability, all Suite B implementations must be at a minimum
and include AES with 128-bit keys, the 256-bit prime modulus elliptic curve, and SHA-
256 as a common mode. Suite B lists the following algorithms that need to be supported
by the platform:
∙ Advanced Encryption Standard (AES) with key sizes of 128-bit and 256-bit of
encryption
∙ The secure hash algorithm for hashing with key sizes of 256-bit and 384-bit
∙ Elliptic Curve Digital Signature Algorithm (ECDSA) using curves of 256-bit and 384-
bit prime modulo for signing
∙ Elliptic Curve Diffie-Hellman (ECDH) using curves of 256-bit and 384-bit prime
modulo for key exchange agreement
These algorithms have been supported by RijndaelManaged, SHA256Managed and
SHA384Managed classes since .NET Framework 1.0. However, these managed
classes are not certified by Federal Information Processing Standards (FIPS).
For more details on FIPS standard and certification 140-2, refer to
http://www.nsa.gov/
ia/industry/crypto_suite_b.cfm
FIPS 140-2 is applicable for sensitive but unclassified information and provides a
third-party, verified security standard for compliance with the Sabanes-Oxley Act,
the Health Insurance Portability Act, and other federal mandates.
19
To contain FIPS-certified and Suite B-compliant cryptographic algorithms, .NET
Framework 3.5 provides managed wrappers such as AESCryptoServiceProvider,
SHA256CryptoServiceProvider and SHA384CryptoServiceProvider.
The managed classes depend on the cryptographic service provider of the underlying
platform. For example, to use FIPS- certified AES algorithms, Windows XP has to
be the underlying platform. To use any of FIPS-certified SHA algorithms, Windows
Server 2003 has to be the underlying platform.
2.2.6.2 Improved Time Zone Support
.NET Framework 3.5 introduces a new class TimeZoneInfo, which is an extension
of the TimeZone class. The TimeZone class recognizes only the local time zone and
converts the local time to Universal Coordinated Time (UTC).
The new class ‘TimeZoneInfo’ allows converting the time in one zone to a
corresponding time in any other zone. It also supports serializing a time zone and
enumerating time zones that are available in a system.
2.2.6.3 Support for International Resource Identifier (IRI)
The Uniform Resource Identifier (URI) type of System namespace is used to represent
web addresses. However, URI supports only a restricted set of characters. It does
not support non-ASCII (Unicode) characters. This forces web addresses or domains
avoid Unicode characters, a severe restriction when the application intends to support
localization as well as globalization requirements.
Actually, web addresses or domains with Unicode characters should be represented
by IRIs instead of by URI, as per RFC 3987. .NET Framework 3.5 enhances the
System.Uri class in such a way that it supports IRI.
20
2.2.6.4 Support for Big Integer Type
The final barrier, the limit for the integer type, is overcome in .NET Framework 3.5. A
variable of a big integer type can have any value that is limited only by the memory
size of the underlying hardware and operating system’s limit.
2.2.6.5 New Extensibility Model to Host Applications Based on Add-ins
It is a certainty that applications being built now will require additional functionalities
in the future. These additional functionalities can also be provided by a third party.
NET Framework 3.5’s support to big integers helps build applications that run on
64-bit operating systems with better virtualization environments. The applications
that deal with huge numbers, for example, astronomical, statistical, financial and
bio-medical applications; benefit from the support for big integers.
Any sophisticated host application in general will require such extensibility, often
referred to as automation. .NET Framework 3.5, with the addition of the System.AddIn
namespace, provides a way to build such extensibility to applications, through its
pipeline-based Add-in model.
2.2.6.6 Inter-process and Collaboration-related Communication
.NET Framework 3.5 introduces two types of pipes for better inter-process
communication. They are: anonymous and named pipes:
I.An anonymous pipe is used for one-way communication between the parent process
and its child process within the boundary of the same machine.
II.A named pipe is used for duplex communication across processes that may exist
within a network boundary.
.NET Framework 3.5 also supplies peer-networking classes to support better
collaboration functionalities. It has introduced a new namespace,
System.Net.PeerToPeer, which facilitates discovery (locating the peers and their
associated network locations dynamically) as well as connectivity (establishing
network connections across peers) of peer applications. An application can
21
Microsoft has announced a community technology preview version of the Sync
Framework, which focuses on peer collaboration and allows for offline synchronization
and data access. This is being built on the synchronization functionality available in
.NET Framework 3.5. This framework is a comprehensive synchronization platform
that enables collaboration and offline scenarios for applications, services, and
devices. Developers can build synchronized ecosystems that integrate any application,
any type of data, using any protocol, over any network. See the useful links section
for the relevant link on this subject.
communicate with peer networks through familiar classes such as Sockets,
HttpWebRequest, WCF peer channel, and so on.
2.2.7 Reflection-related Enhancements
There are two ways to generate an assembly dynamically in the .NET environment –
the CodeDom approach and Reflection Emitting.
While CodeDom helps generate code using specific languages such as C#, VB.NET,
and so on. Reflection Emitting generates raw Microsoft Intermediate Language (MSIL)
code. Depending on the scenario, these approaches are used to generate dynamic
code during the runtime of an application. However, there are severe restrictions for
an application developed using previous versions of .NET Framework, to emit code
using Reflection.Emit such as that it should run in full trust mode. Now, applications
that run with partial trust can emit the dynamic code and execute it.
2.2.8 Tracing-related Enhancements
WMI.NET Provider 2.0 extensions are introduced to easily create WMI providers in
.NET applications. Earlier, WMI interactions were possible only through unmanaged
code.
A class – EventSchemaTraceListener – provides tracking of end-to-end, schema-
compliant events to use for end-to-end tracing of a system that has heterogeneous
components which cross threads, AppDomains, processes, and computer boundaries.
22
To avoid performance impediments, this class is tuned for better logging with implicit
support for lock-free tracing.
It is important to note that Windows Vista has overhauled the Event Log service
to make tracing not only faster, but also scalable and secure. Windows Vista
provides a new infrastructure, called Windows Eventing 6.0, for events and tracing.
This extends the capability of Event Tracing for Windows (ETW) that has been in
use since Windows 2000 and replaces the Event Log Service and the Event Viewer.
2.2.9 ADO .NET Enhancements
2.2.9.1 LINQ to DataSet
It provides LINQ capabilities for disconnected data stored in a DataSet.
2.2.9.2 LINQ to SQL
It supports queries against an object model that is mapped to the data structures of a
SQL server database without using an intermediate conceptual model. Each table is
represented by a separate class, tightly coupling the object model to the database
schema. LINQ to SQL translates language-integrated queries in the object model into
Transact-SQL and sends them to the database for execution. When the database
returns the results, LINQ to SQL translates the results back into objects.
ADO.NET, part of .NET Framework 3.5, also supports the following new features of
SQL Server 2008 (code named “Katmai”):
∙ Table-Valued Parameters: Table-Valued parameters enable multiple rows of data to
be passed as input parameters to SQL Server 2008
∙ Date and Time Data Types: New date and time data types in SQL Server 2008
support greater range, precision, and time-zone awareness
∙ Modifying Data with MERGE: The Transact-SQL MERGE statement introduced in
SQL Server 2008 enables developers to combine INSERT, UPDATE and DELETE
operations into one statement.
These features are supported by the .NET Framework data provider for SQL server
and SqlClient.
23
∙ ADO.NET strives to provide an Entity Data Platform that addresses the issues
related to the tight coupling of the business layer with data layer. Data Access
Layer (DAL) is used to provide a clear separation between the business layer and
the data layer, but ADO.NET Entity Framework is a better and more efficient
mechanism. ADO.NET Entity Framework enables the developers to write code
that operates against conceptual model objects instead of relational model objects.
Conceptual model represents the entities and their relationship in the system being
modeled, but not at a relational- database level. Conceptual model objects can be
generated from an Entity Data Model (EDM). It means that various applications
will have a different set of conceptual model objects through different EDM for
the same database model. Entity Framework also provides better paging and back-
end updating options. Microsoft plans to release most of the components that
constitute the Entity Data Platform (EDMl, Entity SQL, Entity Client, Object
Services, LINQ to Entities) as an extension to .NET Framework 3.5 in future
∙ Microsoft has released Microsoft Synchronization Services for ADO.NET v2.0
CTP1. These services provide the ability to synchronize data from disparate
sources over two- tier, N-tier and service-based architectures
∙ When an application is built based on SOA principles, the data from the back-end
can be exposed as services (Data Services) so that components in other layers can
consume those exposed data services. Through the community technology preview
release of Astoria (officially called ADO.NET Data Services), Microsoft provides
matchless infrastructure for building such next-wave Internet applications. It
enables developers to create and consume data services for the web
∙ To improve data-driven application development productivity, Microsoft released
data components as a framework – codenamed Jasper – for quick and cleaner
data access during Rapid Application Development environment. Jasper takes
advantage of ADO.NET’s Entity Framework’s significant investment on conceptual
models. Jasper dynamically generates the entity model based on the connection
string
2.2.10 WPF Enhancements
For more information, see Chapter 3 WINDOWS PRESENTATION FOUNDATION (WPF).
2.2.11 WF Enhancements
For more information, see Chapter 4 WINDOWS WORKFLOW FOUNDATION (WF) .
24
2.2.12 WCF Enhancements
For more information, see Chapter 5.WINDOWS COMMUNICATION FOUNDATION
(WCF)
2.2.13 Windows Forms Application Development Enhancements
The well-known deployment mechanism of Windows Forms-based applications known
as ClickOnce has been improved, so that now Windows Forms applications can be
deployed from multiple locations without signing again or changing the ClickOnce
manifests of the assemblies.
The .NET Framework has various services such as ASP.NET login, roles and profile
services to carry out functionalities like user authentication, managing authorization
and application settings. Now, .NET Framework 3.5 introduces similar services –
known as “client application services” – and enables Windows-based applications
(including Windows Forms and Windows Presentation Foundation) to easily access
these services. They also support occasional connectivity by storing and retrieving
user information from a local data cache when the application is offline.
Windows Forms support Windows Vista to a great extent now, so it not only works
seamlessly on Vista but has also been upgraded to provide the same appearance as
applications written specifically for Windows Vista, wherever applicable. For example,
common file dialog boxes are automatically updated to the Windows Vista version.
Microsoft has released the .NET Framework 3.5 along with VS 2008 – Microsoft’s
Integrated Development Environment for .NET based applications. Microsoft has
enhanced VS capabilities tremendously to improve productivity to a great extent. The
following table briefly provides a list of significant improvements in VS 2008.
25
Improvements on IDE – VS 2008
Multi-targeting Support
VS 2008 allows developers to write code for specific versions of .NET
Framework like 2.0, 3.0 and 3.5. The IDE also intelligently manages
this information and prevents users from accidentally adding assemblies
from a higher .NET Framework version as references to the project.
Development Productivity Enhancements
It provides better IntelliSense support to JavaScript code. It also carries
out basic syntax validation for JavaScript files, and allows the setting
of breakpoints for debugging JavaScript files. It now supports better
and richer visualization of JavaScript types.
Client-side script files generated from server-side script now appear
in Solution Explorer. Breakpoints set in the server-side script files
are automatically mapped to corresponding breakpoints in client-
side script files.
Debugging Features
It provides remote debugging support for Windows Vista. It provides
better support for debugging multithreaded applications by improving
the Threads window (for example, introduction of Stacktips on the
threads window) and allowing breaking into different threads as they
are executed. Like the ASP.NET Host that can be used to quickly test
ASP.NET applications without having IIS, a similar host is provided
that helps to easily debug WCF services, without having to write custom
test application.
Profiling Features
VS 2008 allows the comparing of different profile runs. VS 2008 profiler
also allows drilling down quickly in the call window to the major
bottlenecks.
26
Improvements on IDE – VS 2008
Code Analysis Features
VS 2008 has introduced some new code analysis features. It introduces
a new tool – Code Metrics – that allows testers to not only get an
overall code-wise health view of the application, but also the ability to
dig deep to find the unmaintainable hotspots or code metrics. VS 2008
supports the following five metrics:
∙ Cyclomatic Complexity
∙ Depth of Inheritance
∙ Class Coupling
∙ Lines of Code
∙ Maintainability Index
Earlier, enhancements were made to analyze anonymous methods and
lambda expressions. New analysis rules for security, globalization,
maintainability, and spelling (including custom dictionary support)
have been provided in VS 2008.Code Analysis check-in policy has also
been modified to provide more control over how settings can be applied
from the policy to projects.
Performance Wizard Features
VS 2008 further extends the Performance-testing capabilities introduced
with VS 2005 and VSTS. Now, it allows the creation of a baseline
performance report. It compares new reports with the baseline version
to easily identify variations between different runs. It also has the
capability to identify hot paths in the performance report via visual
indicators.
Better Support For Development Based on New Technologies
VS 2008 provides better development tools and project templates for
WPF applications, WCF services, Workflow-enabled services, AJAX
27
Improvements on IDE – VS 2008
services, and WF business logic implementation. It also provides
improved visual designers and project templates to support the Entity
Framework of ADO.NET. For example, the visual wizard (Entity Data
Model Wizard), which is a part of VS, helps create an entity or object
based on the conceptual models. The visual designer (codenamed Cider)
for WPF applications is the same as used by Expression Blend and
provides rich editing features for XAML files.
Integrated SQL Express Publishing for Web Developers
In SQL Express that was shipped with VS 2005 (and Visual Web Developer
Express), there was no integrated support to migrate SQL Express
database schema and data to the production SQL Server database.
Such a transfer had been possible only through the Add-in – SQL database
publishing wizard. The wizard now comes integrated with VS 2008.
Source Code Availability
Microsoft has decided to release the source code of .NET Framework
3.5 and VS 2008 to the development community to enable them to
debug .NET-based applications more effectively.
Performance Improvements
VS 2008 has significant performance improvements for some common
development scenarios.
From Somasegar’s blog, we can get the following performance
improvement details on VS 2008.
(http://blogs.msdn.com/somasegar/archive/2007/09/27/vs-2008-performance-
improvements.aspx)
∙ Rebuilding a VB project and running a background compiler is three
times faster and uses one-third the memory
∙ Scrolling large C# files in the Editor is 100% faster, while typing in
new text is 50% faster
∙ The response time of IntelliSense with large types in C# is up to 10
times faster
28
Improvements on IDE – VS 2008
∙ Incremental build time runs up to 90% faster on C++/CLI project
solutions
∙ Word and Excel files are processed 20 times faster on the server
∙ TFS version control command processing was rewritten to support
unlimited-sized operations on key commands without being memory
bound on the server. In our measurements, key commands also run
10% - 60% faster, with the larger improvements associated with
bigger projects
Performance improvements enable the exploitation of multi-core
hardware, by adding multi-threaded support to MSBuild. In addition,
using the /MP switch, C++ project build time can be significantly
improved
VC++ Performance Improvements
VS 2008 has incorporated various enhancements such as faster solution
loading, quicker editor responsiveness and so on into Visual C++
Editor Responsiveness:
Updating IntelliSense, displaying the QuickInfo tooltip
and processing AutoComplete requests will not degrade editor experience
Goto Definition Improvements:
Significant reduction in the time required for
“Goto Definition”. One customer reported that a 2-minute delay dropped to 10-20
seconds
Load Solution Performance:
The loading time for large Visual C++ solutions is
much better. Some customers are reporting that speed has increased by 25%-70%
File Lookup in Projects:
Provides performance improvements to several
processes such as adding files to projects, changing configurations,
and so on
Changing Configuration Options:
Modifying options, such as adding
an include directory or changing the active configuration, is much
faster in large solutions
29
Improvements on IDE – VS 2008
Reduced CPU consumption:
Low-priority background items
are processed (such as IntelliSense population) using 20% less
CPU time
VB.NET Improvements
For VB projects, IntelliSense popup provides auto-filter
support. As the user types characters, the IntelliSense popup
filters out items that do not match from the popup list and
shows only relevant items in it. Additionally, you can hit the
CTRL key to make the IntelliSense window transparent so
that the code below can be easily seen.
Team System Suite-related Improvements
VS Team System includes many additional and enhanced
features in all flavors of team editions.
Team Edition for developers includes a set of software
measures (Code Metrics) that provide better insight into code
quality. Profiling tools have also been enhanced to provide
better Windows Vista support, allocation stacks, and runtime
control. Several components of Team Foundation such as Build,
Source Control, Work Item Tracking, and Server Management
have been improved.
Team Edition for architecture enables the designing of
application systems by using a top-down approach.Team
Edition for testers contains new features and improvements
such as:
∙ Creating and running unit tests in VS Professional Edition
∙ Running unit tests on devices
∙ Providing better web test validation rules
∙ Providing flexible ways to control load modeling in load tests
30
Improvements on IDE – VS 2008
Deployment-related Improvements
Two types of deployment are supported in VS 2008 – Click Once
deployment and Windows Installer deployment. ClickOnce deployment
has been enhanced to support the deployment of WPF web browser
applications. It also provides an option to ISVs to again sign the
application manifest – using strong name signing – to apply their
customer’s own company name, application name and support URL to
it. Now, VS Tools for Office (VSTO) applications can also be published
either through the project designer’s Publish page or the Publish wizard.
It also supports manifest generation under User Account Control on
Windows Vista.Windows Installer deployment is updated to support
targeting applications for the new .NET Framework 3.0 and 3.5 versions.
Now, the user’s installation experience on Windows Vista is smooth
even when the application is run under User Account Control.
Tools for Office-related Improvements
VS Tools for Office in VS 2008 have the following features:
∙ ClickOnce technology to secure and deploy VS Tools for Office solutions
∙ ClickOnce to deploy application-level Add-Ins
∙ Easy creation of Custom Task panes (User interface panels that are
typically docked to one side of a window in a Microsoft Office
application)
∙ Efficient designing of complex ribbons by using the Ribbon designer
∙ Simplifying the SharePoint Workflow development using the
SharePoint Sequential Workflow and SharePoint State Machine
Workflow templates
Support to Popfly through Popfly Explorer for VS
Popfly Explorer is a plug-in for VS to easily create and host a Popfly
(mashup site) website. It also allows us to access our VS solutions from
anywhere and lets us share the solutions with multiple people.
31
Improvements on IDE – VS 2008
“Rosario”, codename for the next version of Team System, is an
integrated Application Life-cycle Management (ALM) solution. It
comprises of tools, processes, and guidance; and helps achieve improved
collaboration in the team, assured software quality and enhanced
visibility into the project. The CTP version of this is available for
download at
http://www.microsoft.com/downloads details.aspx?FamilyId=65D0E3BD-
9DF3-421A-804F-8F01BD90F0B4&displaylang=en
Table 2:Significant Improvements in VS 2008
2.3 Upgrading from .NET Framework 1.0 to .NET Framework 3.5
Here are the steps to follow for the upgrade process.
.Upgrade the code from .NET 1.0 to .NET 1.1 using VS 2003. It has a project
upgrade tool with some assistance.
.Use VS 2008 to upgrade the project from .NET 1.1 to .NET 2.0. The upgrade wizard
in this case does not change the code. It only displays a list of warnings for items
that need modification to make them compatible with .NET 2.0. The changes have
to be carried out manually.
.Once the code is migrated to .NET 2.0, further migration to .NET 3.0 and .NET 3.5
is easy. .NET Framework 3.0 and .NET Framework 3.5 are fairly independent in
their feature set. Hence, .NET Framework 2.0 applications can be directly upgraded
to .NET Framework 3.5. The upgrade primarily enables users to exploit new features
available in the new framework versions. All existing code should work fine. In
fact, it will likely not require recompilation and can be directly run on .NET 3.0 or 3.5.
32
The following is our viewpoint on the new features of .NET Framework 3.5:
Though there are many new features introduced in .NET Framework 3.5, we can
easily classify them into two categories: LINQ-related features and non-LINQ-related
features.
Undoubtedly, the LINQ-related features are one of the most significant additions in
.NET Framework 3.5 as LINQ allows application programmers to be agnostic about
underlying data base objects such as tables, views, stored procedures, and user-
defined functions. This does not mean that database programmers are no longer
needed for application development. Instead, application programmers can now handle
activities related to accessing the database – CRUD activities – using familiar
programming language syntax and object-oriented programming concepts, rather than
resorting to SQL specific concepts. Additionally, developers will not have to handle
back-end data, irrespective of the form and type – relational or hierarchical - differently.
It may take some time for developers to get used to LINQ. However, once this is
accomplished, gains in productivity and code maintenance can be expected.
We believe that other features like object/collection initializers, automatic properties,
and partial methods will help boost the developer’s productivity further and also make
the code more readable and maintainable. Security enhancements made in this release
will make the .NET Framework 3.5 better suited to the needs of government agencies.