Monday, April 20, 2009

Speed up your MSDN Library experience

This tip comes courtesy of Scott Hanselman's blog.

MSDN is now available in a low-bandwidth mode.

Step 1) Goto http://msdn.microsoft.com/en-us/library/default(loband).aspx

Step 2) Click on the link Persist low bandwidth view. It is located in the upper right corner.

Step 3) Enjoy the speedy page access.

kick it on DotNetKicks.com

Saturday, April 11, 2009

Book Recommendation: Framework Design Guidelines (2nd ed.)

The authoritative work by Brad Abrams and Krzysztof Cwalina on .NET framework design was recently updated.

The Book: Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (2nd Edition)

The Blog: http://blogs.msdn.com/brada/archive/tags/Framework+Design+Guidelines/default.aspx

The Blurb:

Framework Design Guidelines, Second Edition, teaches developers the best practices for designing reusable libraries for the Microsoft .NET Framework. Expanded and updated for .NET 3.5, this new edition focuses on the design issues that directly affect the programmability of a class library, specifically its publicly accessible APIs.

This book can improve the work of any .NET developer producing code that other developers will use. It includes copious annotations to the guidelines by thirty-five prominent architects and practitioners of the .NET Framework, providing a lively discussion of the reasons for the guidelines as well as examples of when to break those guidelines.

Microsoft architects Krzysztof Cwalina and Brad Abrams teach framework design from the top down. From their significant combined experience and deep insight, you will learn

  • The general philosophy and fundamental principles of framework design
  • Naming guidelines for the various parts of a framework
  • Guidelines for the design and extending of types and members of types
  • Issues affecting–and guidelines for ensuring–extensibility
  • How (and how not) to design exceptions
  • Guidelines for–and examples of–common framework design patterns

 

Tuesday, April 7, 2009

Enterprise Library 4.1 Hands-On Labs

Microsoft Patterns and Practices has released some Hands-on Labs for Enterprise Library 4.1.

.NET 3.5 and VS 2008 are required.

This set of Hands-on Labs is a guide to learn about the application blocks included with Enterprise Library 4.1 and to leverage their capabilities in various application contexts. It includes Caching, Cryptography, Data Access, Exception Handling, Interception, Logging, Security, Validation, and Unity Hands-on Labs.

Docs for Enterprise Library 4.1 (10/2008) are here.

LINQ Links

The MSDN Site: http://msdn.microsoft.com/en-us/vbasic/aa904594.aspx 

Wikipedia: http://en.wikipedia.org/wiki/Language_Integrated_Query 

LINQ (Language Integrated Query) was delivered in .NET 3.5 and Visual Studio 2008. It addreses O/R mapping issues by making query operations like SQL statements part of the programming language. It also offers built-in support for querying in-memory collections like arrays or lists, XML, DataSets, and relational databases.It also allows you to develop queries in your native development language (with IntelliSense).

LINQ to XML: It is recommended that developers switch over from coding against the XmlDocument DOM to LINQ's XDocument

LINQ to SQL: Deprecated... use LINQ to Entities

LINQ to Entities: Entity Framework Learning Guide

Books:

Wednesday, April 1, 2009

Silverlight 3 Beta

http://silverlight.net/getstarted/silverlight3/default.aspx

Silverlight 3 Beta was unveiled at MIX09. It is a preview release which continues Silverlight’s track record of rapid innovation - introducing more than 50 new features, including support for running Silverlight applications out of the browser, dramatic video performance and quality improvements, and features that radically improve developer productivity.

Important notes:

  • This is a developer beta release only! This means there is no “go-live” licensing available and the end-user runtime of Silverlight 3 is not available. The tools below are intended for software developers only.
  • Once you install the Silverlight 3 Beta Tools for Visual Studio, your development environment will be a Silverlight 3 Beta environment.  Visual Studio 2008 SP1 does not support multi-targeting for Silverlight applications so you will be unable to develop Silverlight 2 applications once these tools are installed.  We recommend that you install the Silverlight 3 Beta tools on a separate environment if you still need to have the ability to develop Silverlight 2 applications.
  • Ensure that you have either Visual Studio 2008 SP1 or Visual Web Developer Express 2008 SP1 installed as it is a prerequisite for the Silverlight 3 Beta Tools for Visual Studio.

Wednesday, March 25, 2009

Google Chrome withstands security testing

From Ars Technica:

A recent contest at CanSecWest, an event that brings together some of the most skilled experts in the security community, has demonstrated that the three most popular browser are susceptible to security bugs despite the vigilance and engineering prowess of their creators. Firefox, Safari, and Internet Explorer were all exploited during the Pwn2Own competition that took place at the conference. Google's Chrome browser, however, was the only one left standing—a victory that security researchers attribute to its innovative sandbox feature.

Monday, March 23, 2009

Dependency Injection, is it for you?

People have been trying to convince you how great Dependency Injection is. Maybe they're calling it Inversion of Control. Either way, you're not buying it.

If you haven't been able to see the benefit, try reading Justin's blog post: To Inject or Not To Inject (warning: it is long, but worth it).

Justin focuses on complex configuration scenarios, but I like to recommend DI for its reusability. Self-configuring and "service locator" configuring tends to constrain you to using a particular type of configuration infrastructure, making it difficult to reuse your components, not to mention unit testing.

Roundup - .NET Application Development Platforms

I've put together a collection of links from around the web on tools and technologies for developing .NET Line-of-business applications.

Silverlight 3 (beta) - Microsoft

Silverlight Labs - Microsoft

Silverlight Toolkit - CodePlex

WPF Hands-on lab (Southridge) - Microsoft Redmond

WPF Hands-on lab (Order Manager) - Microsoft Switzerland

WPF - CodePlex

Composite Application Guidance for WPF and Silverlight (Prism) - Microsoft P&P

Building a Framework for Silverlight - SilverlightShow

Caliburn - Rob Eisenberg

CSLA.NET (WPF and Silverlight) - Rocky Lhotka

DevForce WinClient - IdeaBlade

DevForce Silverlight - IdeaBlade

Nintex Workflow - Nintex

UPDATE: I added RIA services after listening to Brad Abram's talk on .NET Rocks. It was announced at MIX09.

RIA Services - Microsoft

RIA Services on SliverlightShow.

Friday, January 9, 2009

Welcome to Windows 7

7

Do you like to get your hands on the latest and greatest?

Microsoft is posting a beta of its next generation Windows OS later today at the Windows 7 Web page.

Enjoy.

Thursday, January 8, 2009

SharpDevelop

If you are interested in a free Open Source Development Environment for .NET check out #develop (pronounced SharpDevelop). It supports C#. VB.NET and Boo.

Currently it only does .NET 1.1 and 2.0, but they are working on support for .NET 3.5, which will also add IronPython and F#.

Tuesday, December 30, 2008

Unity Application Block 1.2 for Silverlight - December 2008

Not many changes here for Silverlight, just adjustments to the packaging to allow it to run in Silverlight...

Unity Application Block 1.2 for Silverlight - December 2008

And -- not sure how I missed it, but Unity 1.2 was released in October.

Ah, I remember, I was on vacation...

Friday, December 19, 2008

LINQ to SQL - Dead or alive?

Microsoft claims that LINQ to SQL is not a dead technology, despite their focus on Entity Framework. From Redmond Developer News:

Tim Mallalieu, the program manager for both LINQ to SQL and the Entity Framework, ... says Microsoft anticipated the backlash but said both data access interfaces will be better off for this move. For those who don't think the Entity Framework is a suitable replacement, Mallalieu said stay tuned.

"There's some pretty nifty stuff we're doing in the beta 2 time frame that we are not speaking about as yet, I think it will give you a better experience and will reduce the anxiety that people have around the Entity Framework," Mallalieu said. "In terms of capabilities, I think will make the overall integrated experience of ASP.NET, Dynamic Data, MVC and these other things easier, we did a little bit of triaging and feedback, there is some valid feedback around complexity in the Entity Framework and we are doing things to address that. "

Especially in light of the fact that LINQ to SQL is specific to SQL Server, I think it's best to wait a while to see what happens with Entity Framework. Note that there are quite a few folks who aren't happy with the way it has turned out so far.

Wednesday, October 8, 2008

Unity 1.2 and Interception

Unity 1.2 is under development, but we do know that it will support Interception.

David Hayden has a nice screencast showing how it works.

David shows how you can add an interceptor to time the execution of a method in an object that Unity has created for you. Cool stuff. Check it out!

Monday, October 6, 2008

Fun with C# 3.0 (#4) - Nullable types and the ?? operator

C# has reference types and value types. Reference types are commonly called objects, and variables that are declared to be of a reference type can refer to an object or be null. Value types (int or bool, for example) can be stored in variables that contain the actual value, and therefore can never be null.

Sometimes it is useful to have a value type that can have a null value, so this feature has been added to C# 3.0.

This feature is implemented using generics and the type System.Nullable<T>, the shorthand for which is T?. The property HasValue can be used to see if the variable is null. Here's an example:

int? x = 10;
if (x.HasValue)
{
System.Console.WriteLine(x.Value);
}
else
{
System.Console.WriteLine("Undefined");
}

A nullable type can not be assigned to a value type. The following will not compile:


int? x = 10;
int y;
y = x;

Rather use the Value property:


int? x = 10;
int y;
y = x.Value;

Accessing Value will throw an InvalidOperationException if the nullable type is null. Use the ?? to assign a default value.


int? x = null;
int y;
y = x ?? 0;

This is equivalent to:


y = x.HasValue ? x.Value : 0;

Usage of the ?? operator is not limited to Nullable types. For example:


string name = enteredName ?? "Name not entered.";

Friday, October 3, 2008

The Common Service Locator

I have argued against making 'hard' references to an underlying Dependency Injection (or IoC) container; rather, allow the container to do the work for you, namely, inject the dependencies. I realize that it can be difficult in practice, and apparently so have others.

A group of DI container authors have come together to define a common interface for using the underlying containers without creating a hard reference to a particular implementation. This is useful when you are writing code that needs to use a container to resolve a dependency (i.e. get an instance) but you don't know or care what container is being used.

So now we have the Common Service Locator library. Thanks to Ayende for blogging it. UPDATE: Also Glenn Block.

Each container needs an adapter to implement the interface and do the translation from the common method calls to the native container calls. This allows all container references to be declared as Microsoft.Practices.ServiceLocation.IServiceLocator.

Your code has two ways of getting the container:

  • The IServiceLocater reference can be supplied by the calling code and you just use it, or
  • You code can use a static property, ServiceLocator.Current.

Here is the interface that you will use (API Reference):

using System;
using System.Collections.Generic;

namespace Microsoft.Practices.ServiceLocation
{
// Summary:
// The generic Service Locator interface. This interface is used to retrieve
// services (instances identified by type and optional name) from a container.
public interface IServiceLocator : IServiceProvider
{
// Summary:
// Get all instances of the given TService currently registered in the container.
//
// Type parameters:
// TService:
// Type of object requested.
//
// Returns:
// A sequence of instances of the requested TService.
//
// Exceptions:
// Microsoft.Practices.ServiceLocation.ActivationException:
// if there is are errors resolving the service instance.
IEnumerable<TService> GetAllInstances<TService>();
//
// Summary:
// Get all instances of the given serviceType currently registered in the container.
//
// Parameters:
// serviceType:
// Type of object requested.
//
// Returns:
// A sequence of instances of the requested serviceType.
//
// Exceptions:
// Microsoft.Practices.ServiceLocation.ActivationException:
// if there is are errors resolving the service instance.
IEnumerable<object> GetAllInstances(Type serviceType);
//
// Summary:
// Get an instance of the given TService.
//
// Type parameters:
// TService:
// Type of object requested.
//
// Returns:
// The requested service instance.
//
// Exceptions:
// Microsoft.Practices.ServiceLocation.ActivationException:
// if there is are errors resolving the service instance.
TService GetInstance<TService>();
//
// Summary:
// Get an instance of the given named TService.
//
// Parameters:
// key:
// Name the object was registered with.
//
// Type parameters:
// TService:
// Type of object requested.
//
// Returns:
// The requested service instance.
//
// Exceptions:
// Microsoft.Practices.ServiceLocation.ActivationException:
// if there is are errors resolving the service instance.
TService GetInstance<TService>(string key);
//
// Summary:
// Get an instance of the given serviceType.
//
// Parameters:
// serviceType:
// Type of object requested.
//
// Returns:
// The requested service instance.
//
// Exceptions:
// Microsoft.Practices.ServiceLocation.ActivationException:
// if there is an error resolving the service instance.
object GetInstance(Type serviceType);
//
// Summary:
// Get an instance of the given named serviceType.
//
// Parameters:
// serviceType:
// Type of object requested.
//
// key:
// Name the object was registered with.
//
// Returns:
// The requested service instance.
//
// Exceptions:
// Microsoft.Practices.ServiceLocation.ActivationException:
// if there is an error resolving the service instance.
object GetInstance(Type serviceType, string key);
}
}



Here are the containers that have adapters at the moment:





I recommend IServiceLocator be used in all components that might need a reference to a container. Note that they are no common calls for configuring the container because this is a container-specific task that should be handled in the calling code.

Thursday, October 2, 2008

Microsoft "Dublin" addresses composite SOA applications

Microsoft just released a white paper outlining how .NET Framework 4.0 and new Windows Server capabilities (code-named Dublin) will help developers design, build and maintain Composite Applications. The white paper is available here.

What are composite SOA applications? Applications that are composed by assembling and integrating reusable services. This makes the deployment and management of applications (and servers) more complex and creates new requirements to address scalability, performance and reliability.

Microsoft has announced .NET Framework 4.0 to add functionality to WCF and WF, and also "Dublin", an add-on to Windows Server 2008, that will make SOA applications and servers easier to deploy, configure, manage and scale. The first preview will be available at the PDC at the end of October.

See the chart below from the white paper:

 

Windows Communication Foundation 4.0

Windows Workflow
Foundation 4.0

Windows Server
"Dublin" technologies

RESTful enhancements

·   Simplifying the building of REST Singleton & Collection Services, ATOM Feed and Publishing Protocol Services, and HTTP Plain XML Services using WCF

·   WCF REST Starter Kit to be released on Codeplex to get early feedback

Messaging enhancements

·   Transports - UDP, MQ, Local in-process

·   Protocols - SOAP over UDP, WS-Discovery, WS-BusinessActivity, WS-I BP 1.2

·   Duplex durable messaging

Correlation enhancements

·   Content and context driven, One-way support

Declarative Workflow Services

·   Seamless integration between WF and WCF and unified XAML model

·   Build entire application in XAML, from presentation to data to services to workflow

 

Significant improvements in performance and scalability

·   Ten-fold improvement in performance

New workflow flow-control models and pre-built activities

·   Flowcharts, rules

·   Expanded built-in activities – PowerShell, database, messaging, etc.

Enhancements in workflow modeling

·   Persistence control, transaction flow, compensation support, data binding and scoping

·   Rules composable and seamlessly integrated with workflow engine

Updated visual designer

·   Easier to use by end-users

·   Easier to rehost by ISVs

·   Ability to debug XAML

Provide standard host for WF and WCF applications   

Pre-built developer services

·   Message-based correlation

·   Message forwarding service

·   Content-based message routing

·   Compensation service for long-running transactions

Greater scalability and easier manageability

·   Enable scale-out of stateful workflow applications

·   Persisting and rehydrating state for high scalability

·   Enhanced management and monitoring functions

·   Tracking store for workflow events

Supports “Oslo” modeling platform

 

 

Key takeaways:

  • Microsoft will make it easier to design applications as WF workflows that are easily integrated into WCF services.
  • WCF and WF both use XAML. Microsoft will move to a "unified" XAML to make the integration easier.
  • Microsoft is moving more toward REST for web services due to its simplicity. The REST Starter Kit will be available on Codeplex in the near future.
  • The server infrastructure (Dublin) to host and manage these new types of applications will become available after .NET 4 and Visual Studio 2010 ship.

Links: