Thursday, March 20, 2008
Microsoft .NET Framework 3.5 Certification Exams
Monday, March 17, 2008
Inside Visual Studio 2008
Visual Studio is designed as a container environment that integrates the functionality of multiple visual designers for just about any supported type of application and component. This means you have readymade templates for a variety of Windows and web application types, including Windows Forms, Windows Presentation Foundation (WPF), ASP.NET sites, and web services. In addition, Visual Studio 2008 offers ad hoc designers for creating workflows and Windows Communication Foundation (WCF) services. The characteristics of each output component are managed through projects, and in turn grouped in solution containers.
The true added value of Visual Studio—and perhaps the primary reason to consider upgrades—is the boost it gives to developer productivity. Dozens of wizards, smart and context-sensitive popup windows, effective debuggers, and visual designers are examples of facilities that may not necessarily make any code automatically smarter, but still help you focus on key points—skimming over chores, repetitive tasks, and overzealous procedures.
Multitarget Projects
Have you noticed that previous releases of Visual Studio only supported one version of the .NET Framework? For years, my desktop was swarming with shortcuts to different versions of Visual Studio based on the projects I maintained at the time: Visual Studio 2002 for .NET Framework 1.0 applications, Visual Studio 2003 for .NET Framework 1.1, and Visual Studio 2005 for .NET Framework 2.0 applications. Finally, Visual Studio 2008 introduces a cool feature called “multitargeting” that lets us create applications for specific versions of the .NET Framework.
Multitargeting brings two main benefits to the table:
- You no longer need to install two or more different versions of Visual Studio to deal with the various clients and projects.
- You are no longer subliminally invited to upgrade to the next, super-cool version of .NET because of the new, super-cool time-saving features of the next Visual Studio. One IDE fits all .NET Frameworks, you could say. All frameworks? Well, not exactly.
Figure 1: Choosing a target platform for a Visual Studio 2008 project.
Figure 2: Upgrade the target .NET of an existing project.
The target platform is not a definitive choice. At any moment, you can upgrade or downgrade to any of the supported targets. You do this from the property pages of the project in the Solution Explorer (Figure 2). Should you install Visual Studio 2008 if you’re mostly maintaining existing .NET Framework 2.0 applications? Clearly, the big news about Visual Studio 2008 is the support it offers for 3.x .NET applications. However, even from a platform-agnostic perspective, there’s something it offers—an improved set of facilities with a particular attention to web developers. JavaScript debugger, CSS, master pages designer, and LINQ helper tools are all features available independently from the target platform.
Some C# and VB Syntactic Sugar
In Visual Studio 2008, C# and Visual Basic offer a few time-saving features that basically give the compiler the burden of creating some required code. In the end, these features are just syntactic sugar that make C# and VB programming easier and more pleasant.
“Automatic properties” is a feature that instructs the compiler to automatically add a default implementation for the getter/setter methods of a class property. This code is now perfectly legal in a class compiled with the newest C# compiler:
public string ContactName { get; set;}
The compiler automatically expands thiscode like this:
private string contactName;
public string ContactName
{
get { return contactName; }
set { contactName = value; }
}
Automatically generated get/set properties are not equivalent to public fields. From a metadata perspective, properties and fields are quite different entities. The idea here is that you just delegate to the compiler the creation of some plumbing code, in the most common and simple scenario. At a later time, you can always come back and provide your own getter/setter methods.
Object initializers are another piece of syntactic sugar to speed up the creation of the code that initializes an object. Instead of going through a potentially long list of assignment instructions, you can code it like this:
Person person = new Person {
FirstName="Dino",
LastName="Esposito", Age=24 };
The idea is extended to collections, as in this code:
List
{ new Person {FirstName="Nancy", LastName="Davolio", Age=28 },
new Person { FirstName="Andrew", LastName="Fuller", Age=35 },
:
};
Compared to the syntax required in Visual Studio 2005, the savings is pretty clear and can easily sum up to tens of lines of code for large procedures.
Richer Languages Beyond the Sugar
Programming languages are not immutable. Especially when they’re tightly coupled to a runtime environment such as the CLR, they progress as the underlying machinery is refined and enhanced. For example, the .NET Framework 2.0 supplied a C# compiler with additional features compared to the compiler for the .NET Framework 1.x. In Visual Studio 2008 and with .NET 3.5 onboard, you can use a significantly richer C# and Visual Basic .NET languages.
Both languages now incorporate features that enable functional programming and add specific keywords for Language Integrated Queries (LINQ).
Extension methods are a way to extend the otherwise hard-coded contract of a class by adding new methods programmatically without creating a derived or partial class. The idea behind extension methods is bringing the flexibility of duck-typing to a strongly-typed and compiled environment such as the CLR. In practice, you may use extension methods whenever you feel that a given class you’re using lacks a helpful method. If you have no access to the source code of this class, in Visual Studio 2008 you define an extension. Extension methods can be defined for any class, including native classes of .NET. Listing One shows how to extend the System.String class with a few methods such as IsDate, IsInt32, and ToDate.
Listing One
namespace Samples
{
public static class StringExtensions
{
public static bool IsInt32(this string content)
{
int number;
bool result = Int32.TryParse(content, out number);
return result;
}
public static bool IsDate(this string content)
{
DateTime date;
bool result = DateTime.TryParse(content, out date);
return result;
}
public static DateTime ToDate(this string content)
{
DateTime date;
bool result = DateTime.TryParse(content, out date);
if (result)
return date;
else
return DateTime.MinValue;
}
public static int ToInt32(this string content)
{
int number;
bool result = Int32.TryParse(content, out number);
if (result)
return number;
else
return Int32.MinValue;
}
}
}
An extension method is defined as a static method on a static class. The binding between the method (say, IsInt32) and type (say, System.String) is established through the this keyword in the method’s prototype:
public static bool IsInt32 (this string content)
The type that follows the this keyword is treated as the type to extend.
The following code illustrates how you can use these new methods in your code:
void btnDate_Click(object sender, EventArgs e)
{
string content = textBox1.Text;
if (content.IsDate())
{
DateTime date =content.ToDate();
label2.Text = String.Format("Next day is {0}",date.AddDays(1).ToString("dd MMMM yyyy"));
}
else
label2.Text = "Not a valid date.";
}
Extension methods are checked at compile-time and can be applied also to any parent class or interface in .NET. (Extension methods could be used to obtain a feature that looks similar to mix-ins. Overall, a mix-in is a sort of interface with implemented methods. A class that implements a mix-in includes—but not inherits—all the members on the mix-in’s interface. Currently, C# and Visual Basic .NET don’t natively support mix-ins, even though instructing the compilers to produce the code for it didn’t appear to be a huge effort. With extension methods, you can simulate mix-ins in the latest C# and Visual Basic .NET.)
The var keyword is another interesting new entry. Used to qualify a variable, it doesn’t indicate a late-bound reference. Instead, it merely indicates that you don’t know the type of the variable at the time of writing. However, the type won’t be determined at runtime (late-binding), but the compiler infers the type from the expression assigned to the var variable. For this reason, an initial value assignment is required to avoid a compiler error. When var is used, a strongly typed reference is always generated.
The var keyword enables another cool C# feature—the anonymous type. This is an unnamed type that you define using the same object initializer syntax mentioned earlier:
var person = new { FirstName="Nancy", LastName="Davolio", Age=28 };
For the CLR, anonymous and named types are exactly the same entity. Anonymous types can be used in a variety of scenarios, but have been introduced primarily to support LINQ queries. The same can be said for lambda expressions. Lambda expressions are used as a convenient way to create delegates, especially (but not uniquely) in LINQ. In .NET, a delegate is an object-oriented wrapper for a function pointer and points to an existing and named function in a class. In .NET 2.0, managed languages offered new, powerful construct—anonymous methods. Basically, you have an explicit code snippet defined inline and used as an unnamed method of some class. Lambda expressions are a further refinement of the idea of an anonymous method, just less verbose and niftier.
LINQ Facilities
Most Windows and web applications are centered on some sort of data repository, usually a relational database. To retrieve data, you have to use a different API each time. It can be SQL for relational databases, XQuery and XPath for XML documents, some interface (ICollection, for instance) for collections and arrays. The main goal of LINQ is unifying this model by providing an ad hoc framework. Conveniently, this query framework is wired to some new keywords in C# and VB:
int[] fiboNumbers = new int[] {0,1,1,2,3,5,8,13,21,34};
var data = from n in fiboNumbers
where n % 2 == 0
select n;
As weird as it may seem, this is C# code that compiles in Visual Studio 2008. The new keywords are from, where, and select. Their meaning is really close to the meaning that analogous keywords have in SQL. Translated to human language, the query assigns to the data variable all elements in the queryable object (a collection, in this case) that match the specified condition (all even numbers in this case). Here’s another LINQ expression that uses lambdas:
var data = (from c in customers
where c.Country == "USA"
select c).SelectMany(c => c.Orders);
A lambda expression is characterized by the => operator, prefixed by input parameters, and followed by the parametric expression to evaluate. The preceding code selects all U.S. customers and flattens the result set to a list of orders. Without the SelectMany keyword and the input lambda, you’ll get an array of collections of orders—not a list of order objects.
LINQ operators work on objects that implement a particular interface IQueryable. .NET 3.5 counts a number of these objects. They are wrappers for wellknown data containers such as collections, XML documents, DataSets, and SQL Server databases. The model is extensible too, so third-parties can provide their own LINQ engine to query Oracle databases or perhaps the filesystem.
The most interesting of LINQ queryable objects is the object that wraps a SQL Server 200x database. It is a user-defined class that inherits from a base class named DataContext. Visual Studio 2008 provides an ad hoc visual tool called “O/R designer”; see Figure 4. After you set up a database connection in the Server Explorer window, you drop tables and stored procedures in the designer and get a dynamically generated class to work with. Next, you simply instantiate this class and use it as the queryable object:
NorthwindDataContext dataContext = new NorthwindDataContext();
var data = from c in dataContext.Customers
where c.Country == "Spain"
select c;
You can then go through the returned result set using a for/each statement or just bind the object to a data-bound control.
Visual Studio 2008 Projects
LINQ facilities span over all types of projects where database access and queries make sense. But other improvements are specific to web projects. For example, the editor of master pages has been enhanced to fully support nested master pages. Nested master pages were already working in ASP.NET 2.0, but were not fully backed by the visual designer of Visual Studio 2005. In addition, Visual Studio 2008 delivers support for split-view editing and a new CSS designer. A JavaScript debugger and IntelliSense extended to JavaScript classes complete the offering for web developers. From the framework perspective, the .NET Framework 3.5 has built-in support for AJAX that goes a little beyond what was already released as ASP.NET AJAX Extensions 1.0 for ASP.NET 2.0. In addition to features such as UpdatePanel and ScriptManager, you find AJAX-enabled Web Parts, WCF support for JSON, plus bug fixes and performance improvements.
On the Windows side, in Visual Studio 2008 you finally have a true WPF designer with a toolbox and a classic Properties box. Figure 4 previews the feature.
Visual Studio 2008 also has flavors specifically created to facilitate tests and full application management, such as Visual Studio 2008 Team Suite and Visual Studio 2008 Team Foundation Server. The good news is that unit testing support is not just faster, but is included in the Professional edition of Visual Studio 2008.
WCF and Workflow Support
Version 3.0 was the first version of .NET to ship without a dedicated version of Visual Studio. Microsoft released a few extensions to Visual Studio to make it easier for developers to build WCF services and workflows, but in fact it just separates downloads. WCF and workflow projects and related renewed designers are included in Visual Studio 2008. Figure 6 shows the workflow designer whose toolbox distinguishes between version 3.0 and 3.5 activities. The newest activities include an activity to send and receive JSON data to and from a WCF service.
Conclusion
Visual Studio is Microsoft’s flagship for developers, and Visual Studio 2008 is the first version of Visual Studio to support multiple version of .NET. You can choose the target platform when you create the project and find around you an IDE that offers only controls and components adequate to the target platform. The improved capabilities of editors and designers, though, are shared by all projects, regardless of the platform. Visual Studio 2008 fully integrates in the IDE tools for creating workflows as well as WCF and WPF assemblies. It also brings in AJAX capabilities in ASP.NET web projects and adds JavaScript to the list of languages for which it can offer serious debugging and IntelliSense features. Available in a variety of formats such as Standard, Professional, and Team Suite, it is also available in free Express versions.
Thursday, August 9, 2007
.NET Framework 3.0 - Introduction
Abstract
The .NET Framework 3.0 is the next generation of the .NET Framework that sits on
the top of the previous version. It introduces some additional features, and in
this article discussed these features in detail.
Article Contents:
- Introduction
- What Happens when we install Framework 3.0 ?
- Features
- Windows Presentation Foundation (WPF)
- Windows Workflow Foundation (WF)
- Windows Communication Foundation (WCF)
- Microsoft Windows Card Space (WCS)
- Related Downloads
- References
- Conclusion
Introduction
[ Back To Top ]
I have been come across many people thinking that WinFx is not related to .NET Framework. The funniest answer I have gotten is that it is a fix related to Windows PC protection similar to WinFix. It is good decision from Microsoft for changing its name from .NET Framework 3.0. This article gives a clear explanation about the
additional technologies/features that are included in .NET Framework 3.0, namely
Windows Presentation Foundation (WPF), Windows Workflow Foundation (WF), Windows
Communication Foundation (WCF) and Windows Card Space (WCS).
What Happens when we install Framework 3.0?
[ Back To Top ]
Does it install new version of the Framework? No. It is just an upgraded Framework from 2.0 that comes along with WPF (Avalon), WCF (Indigo), WCS (InfoCard) and WF. It is a Framework that sits on the top of the 2.0 Framework along with Common Language Runtime (CLR) and BCL (Base Class Library). Framework 3.0 comes with CLR version 2.0. We are still using version 2.0 compilers for the Framework 3.0. So if we have Framework 2.0 installed in our system, it will install managed API’s that are required for workflow, presentation, communication, etc. If Framework 2.0 is not installed, it will install Framework 2.0 and then install all other upgraded required components. The serious question that comes to mind is “why the version number is changed if we are still using 2.0 compliers.” The reason for choosing the new version number is Avalon, Indigo, Workflow, and Info card are all major new pieces of platform technology.
[ Back To Top ]
· Managed Code Programming Model
· Includes WWF, WPF, WCF
· Delivers sophisticated User Experience
· New user interface code model with vector graphic support using WPF
· Advanced web services functionality using WCF
· Built in work flow for advanced business applications using WF
· Advanced security against phishing using WCS
The below diagram (Figure 1) illustrates the architecture diagram of .NET Framework 3.0
Figure 1

Framework 3.0 is a layer above the .NET Framework 2.0 with the 4 major new components as mentioned earlier. The .NET application development takes place above the Framework 3.0. There is no up gradation to Visual Studio 2005, CLR 2.0, ADO.NET 2.0 and base class library. All these are part of .NET Framework 2.0. These technologies are developed as managed code API’s, therefore, all these technologies can be used in any .NET supported programming languages like C#, VB, J#, etc.
Windows Presentation Foundation (WPF)
[ Back To Top ]
This is formerly known as the code named “Avalon,” a graphical feature in Framework 3.0 that makes easy to build next generation web applications with the help of rich User Interface (UI), documents and media. This is used to display more advanced graphics that helps a developer to improve his/her designing skills using programming skills, which would be quite challenging. We developers can produce outstanding user interfaces using multimedia and document services in WPF. We can also make use of vector graphics, user interface, 2D and 3D drawing, fixed and adaptive documents, typography, raster graphics, animation, data binding, audio, video and develop graphic/animation through declarative programming. WPF allows developers as well as designers to collaborate and develop awesome visual user interfaces. Here are the two different developer environments that are used to make developer and designer work together.
1. Microsoft Visual Studio
2. Microsoft Expression Interactive Designer
The language that is used to develop application user interfaces in WPF is called XAML (Extensible Application Markup Language). XAML is based on XML (Extensible Markup Language). Separation of model and view is possible in XAML by placing design related information in FileName.xaml file and business logic is placed in FileName.xaml.cs file.
Core Components
The major components of WPF are:
1. Presentation Framework
2. Presentation Core
3. MILCore (Media Integration Layer)
4. DirectX
Presentation Framework and Presentation core are written in managed code. The DirectX engine is responsible for displaying. MILCore is written in unmanaged code in order to enable tight integration with DirectX. MILCore (MILCore.dll) also consists of a composition engine which is responsible for performance reasons.
Microsoft Silverlight
WPF comes with its subset Microsoft Silverlight formerly named as Windows Presentation Foundation Everywhere (WPF/E) and is a subset of WPF which depends on XAML and JavaScript.
Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences for the Web and mobile applications. Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. It is lightweight, just 1 MB download and pretty fast. We can play many videos simultaneously without stuttering or dropping frames. No doubt WPF is next-generation graphics API. More explanation on Silverlight is out of the scope of this article. For more details on Silverlight, visit
http://www.microsoft.com/silverlight.
Windows Workflow Foundation (WF)
[ Back To Top ]
“Workflow” is a declarative way of implementing result oriented business process in software. WWF is a programming model that helps in defining, building, executing, debugging and managing work flow related applications that are in sync with business processes. It consists of a Microsoft NET Framework version 3.0 namespace, an in-process workflow engine, and designers for Visual Studio 2005.
We can build as many work flow styles as we need based on the requirement.
Graphical designer and debugger are provided to implement work flow related software. We can make use of imperative code along with declarative modeling. It enables us to build workflow software that is more flexible and transparent.
Core Components
WF core components include:
1. Base Activity Library: This provides functionality for control flow, conditions, event handling, state management and invoking web service. One can build his or her own custom domain specific activities using the base activity.
2. Runtime Engine: This is responsible for Workflow execution and state management.
3. Runtime Services: This provides hosting flexibility and communication.
4. Visual Designer: It is responsible for graphical and code-based construction.
Once a workflow model is compiled, it can be executed inside any windows process including console applications, WinForms applications, Windows Services, ASP.NET Web sites, and Web services. Extensible Object Modeling Language [XOML] based on XAML is the language that is used for declaring the structure of workflow, business logic for the workflow.
In order to create workflow, activities using WWF are:
1. VS 2005 (comes by installing Visual Studio 2005 add-ins to design and program workflow)
2. SharePoint designer that permits building workflows for Share Point 2007
Windows Communication Foundation (WCF)
[ Back To Top ]
WCF is formerly known as the code “Indigo” is the first Unified Programming Model (UPM) for Service Oriented Applications (SOA). It is the unification of the technologies used to deliver distributed systems such as Enterprise Services, Messaging, .NET remoting, ASMX and WSE that run on the Microsoft platform. In other words, Windows Communication Foundation is an advanced technology to provide web services/remoting functionality with better features and reduces the time to develop a distributed system. It makes development interoperable with Non-MS Platform and integrates with existing products. We can build amazing services that would add more weight using WCF. WCF uses SOAP messages for communication between two processes. WCF has a set of API’s for creating systems that send messages between services and clients. The same API’s are used to create applications that communicate with other applications on the same system or on a system that resides in another company.
Core components
Here is a list of core components in WF.
1. End Point: A WCF service is exposed to the world as a collection of endpoints.
It is the point where messages are sent or received. It consists of Address, Binding and Contract.
Address: End point consists of location where message can be sent/received.
This is equivalent to a service address in WSDL. An example of Address components are URI, Identity & Headers.
Binding: This is a communication mechanism that describes how messages can be sent. This represents configuration. It is made up of various binding elements like Transport protocol, such as TCP, HTTP, MSMQ, named pipes, Encoding such as text, Message Transmission Optimization Mechanism such as MTOM, binary, and security like asymmetric, symmetric and transport.
Contract: It is a definition for a set of messages that can be
sent or received (or both) at the address that describes what message can be sent.
It describes the WCF contracts and their operations like One way, request/reply, duplex, and queuing.
2. Channel: A channel is a concrete implementation of a binding element. The channel is the implementation associated with that configuration.
3. Client: A program that exchanges messages with one or more endpoints using channels.
4. Service: A service is a construct that exposes one or more endpoints, with each endpoint exposing one or more service operations.
5. Behavior: A behavior is a component that controls various run-time aspects of a service, an endpoint, a particular operation, or a client.
· WCF has rich communication capabilities.
· WCF is 25%—50% faster than ASP.NET Web Services and approximately 25% faster than .NET Remoting.
· It is secured, Confidential in keeping messages.
· Using WCF message transfer is reliable.
Microsoft Windows Card Space (WCS)
[ Back To Top ]
It is formerly known as the code named “InfoCard” that helps to protect user’s digital identities against spoofing, phishing and tampering. It enables end users to provide digital identity to online services in a simple and trusted way.
Here is how it works…
Instead of authenticating users with passwords, websites authenticate users with security tokens. Submit identity token to the website with just a few clicks of a mouse. The website accepts this token presented by the user, decrypts the token, validates this credential and uses this information internally to identify the user. Cryptographic techniques along with responsible protocols are used for identification of the user. CardSpace includes a self-issued identity provider, which runs on the local Windows system and it can produce information cards just like any other identity provider.
Users download cards from identity providers such as their bank, employer, government agency, membership organization, or create their own self-issued cards. When a Website or Web service requests a user’s credentials, CardSpace will be invoked and allow the user to select a card to present. CardSpace then retrieves a verifiable credential from the selected identity provider, or the self-issuing authority as the case may be, utilizing interoperable protocols. It then forwards the credential to the target application. This provides users with a simple, secure and familiar sign-on experience that is consistent across all Websites and Web services.
We can enjoy the technology, simplicity, consistency and mainly security that Card Space gifts us.
[ Back To Top ]
Microsoft .NET Framework 3.0 Redistributable Package
Description: The Microsoft .NET Framework version 3.0 redistributable packages install the common language runtime and associated files required to run applications developed to target the .NET Framework 3.0.
Description: The Windows SDK includes content for application development with the API’s in Windows Vista, including the .NET Framework 3.0 technologies:
.NET Framework 2.0, Windows Presentation Foundation, Windows Communication Foundation, Windows Workflow Foundation, and Windows Card Space. This SDK is designed for use with Windows Vista (which includes Framework 3.0). This release of the Windows SDK is compatible with Microsoft Visual Studio 2005 and the Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP.
Visual Studio 2005 extensions for the .NET Framework 3.0, featuring plug-ins and
templates to enable developers to use Visual Studio 2005 to build .Net Framework
3.0 applications
Visual Studio 2005 extensions for .NET Framework 3.0 (Windows
Workflow Foundation)
Description: This version of Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation) requires the final released version of Windows Workflow Foundation Runtime Components, Microsoft Windows Vista, or the .NET Framework 3.0 Runtime Components.
4.Visual Studio 2005 extensions for .NET Framework 3.0 (WCF
& WPF), November 2006 CTP
Description: The Visual Studio 2005 extensions for.NET Framework 3.0 (WCF & WPF), November 2006 CTP provides developers with support for building .NET Framework 3.0 applications using the released version of Visual Studio 2005.
Microsoft Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web. Silverlight offers a flexible programming model that supports AJAX, VB, C#, Python, and Ruby, and integrates with existing Web applications. Silverlight supports fast, cost-effective delivery of high-quality video to all major browsers running on the Mac OS or Windows.
[ Back To Top ]
Microsoft .NET Framework 3.0 Community (NetFx3) Virtual Labs
Microsoft .NET Framework 3.0 Programming Model
Windows Presentation Foundation (WPF)
Windows Communication Foundation (WCF)
Introducing Windows CardSpace
Windows Workflow Foundation Overview
Files: ASP.NET Control for CardSpace
[ Back To Top ]
This article provided a complete overview on .NET Framework 3.0 and the features
included in it. I will be discussing each of these technologies in depth in upcoming
articles. So keep visiting ASPAlliance.com!
Note: Framework 3.0 does not include LINQ, DLINQ and all the new features that are included in C# 3.0. These features are going to be included in the next release ORCAS. NET FX 3.0 is supported on XPSP2, Win2k3, and Vista.
Upcoming Framework 3.5: As mentioned earlier it includes new language features, LINQ, DLINQ, 3.0 version of CLR, new classed for base class library and VS 2008 support for WF, WCF, WPF that includes new workflow-enabled services technology.
Reference:
ASP Alliance
http://msdn2.microsoft.com/en-us/winfx/Aa663314.aspx