mercredi 17 octobre 2007

Design Pattern Singleton optimized for .Net

Here is the most popular version of the implementation of this design pattern :

public class Singleton
{
private static Singleton instance;
private object oSync = new object();

public Singleton ()
{
}

public static Singleton Instance

{
get
{
if(instance == null)
{
Lock(oSync)
{
if(instance == null)
{
instance = new Singleton();
}
}
}

return instance;
}
}
}

this version is not optimized for .Net. In .Net we can use a static constructor and this static constructor is ThreadSafe.
Here is the optimized version :

public class Singleton
{
private static Singleton instance = new Singleton ();
private object oSync = new object();

static Singleton ()
{
}
private Singleton ()
{
}

public static Singleton Instance

{
get
{
return instance;
}
}
}

jeudi 27 septembre 2007

SSIS Excel data source values returned as null

This problem occurs when we try to import an Excel file. All values of a column are returned in SSIS as null values but in the document we had values.
The problem is due to the provider : the provider calculate the data type of a column by analysing the first lines of the document.
The solution is to modify the ConnectionString property of the ExcelConnection component (add IMEX=1)
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\data\maroc\import.xls; Extended Properties="EXCEL 8.0;HDR=YES;IMEX=1;"
IMEX=1: indicates the provider to convert data, in multitype columns, to text values.

SEE :http://support.microsoft.com/kb/194124/en-us

Building ClickOnce application from the command line(Without VS2005)

I was looking for an alternative to use VS 2005 for publishing an application, And I found that MSBuild allow us to do that. the solution consists of using the .csproj file generated by visual studio and this command line : msbuild /target:publish.
A detailed explanation is available here : Building ClickOnce Applications from the Command Line

mardi 18 septembre 2007

Nouveauté du framework 2.0

ayant travailler essentiellement sur .Net 2.0, je ne pouvais pas répondre à cette question qui est souvent posé lors des entretient d'ambauche : quelles sont les nouvautés du framework 2.0 ?
Des éléments de réponses sont disponible à cette adresse :

Les nouveautés du framework 2.0

lundi 17 septembre 2007

Welcome to .Net Generation

In this blog you will find essentially, technical postes about .Net technologies.