Saturday, August 30, 2008

GetHashCode() have been changed

As its written in MSDN (
The behavior of GetHashCode is dependent on its implementation, which might change from one version of the common language run-time to another. A reason why this might happen is to improve the performance of GetHashCode.

In the following versions exactly this happens:

  • 2.0.50727.3053

  • 2.0.50727.1433

Let's say you like to do something for load-balancing based on the following code:

return Math.Abs((key.GetHashCode() % serverAmount));

it will return a different server node in case of shared cache. To handle this issue we have added 2 things, first of all is an alternative hashing algorithm and second we check the run-time between clients and server and inform clients about it in case this happens.

If you are using a version of shared cache which is below you need to keep all your systems up-to-date with the same CLR version or you decide to use a different hashing algorithm for your system. Within our notifier program you can check this quite easily.

To use following options you will firstly need to register, the registration can be done during installation or afterwards within a new option within menu context of Notify application.

  • Check if all environments are using same CLR

  • A Test to check if you able to use all Hashing Algorithms

  • Get Informed if your environment is using same version of shared cache, this is mostly important to grant all communication options between clients and caching nodes on your servers.

for more information about hashing algorithms which are supported by shared cache visit my website: - or go directly to

Friday, August 29, 2008

LINQ to SQL Serialization

Use the Generics, Extension and Reflection features to implement a generic serialization class library for LINQ to SQL classes

Tuesday, August 26, 2008

Build a Web Chat Application using ASP.Net 3.5, LINQ and AJAX (in C# 3.5)

Junnark Vicencio explains how to build a chat application within 2 hours.

Technologies Used: ASP.Net 3.5, AJAX, JavaScript, C# 3.5, LINQ-to-SQL, MS SQL Server 2000/2005

Thursday, August 14, 2008

Check if server is available before you make requests

I had to implement a fallback system in case one of my primary servers is not available anymore because of any reason. There were no option to access servers over a loadbalancer or something else then a direct routing to each server.

After some compassion's how much time I gone waste for each request between usage of sockets or HttpWebRequest / WebRequest I decided to work directly with Sockets.

The implementation I decided to go for were quite easy (remember: keep it simple as possible) and its fast like hell - 9ms I'm loosing each check if the server is available or not. We use 2 servers - so I have to remember that there is a total of 18ms I'm loosing each time we have a running cycle to analyse data. In general my tests gave showed me that 5 of the 9 ms are used for DNS.GetHostEntry(ServerName) - if you can use IP-Addresses then I suggest to do it that way. Check out one of my previous post about this DNS.GetHostEntry(ServerName) - IPAddress.Parse("") vs. Dns.GetHostEntry("")

With those ~20ms we can leave very good because a cycle needs right now something around 2.5min and it can be a max. of 15min. So how to solve this is the question, here the codesample from MSDN which I adapted and using to validate if my servers are online:

Formatted Code is available here:

   1:      private static bool ConnectSocket(string server, int port)

   2:      {

   3:          Stopwatch sp = new Stopwatch();

   4:          IPHostEntry hostEntry = null;

   5:          bool result = false;

   6:          sp.Start();

   7:          // Get host related information.

   8:          hostEntry = Dns.GetHostEntry(server);

   9:          sp.Stop();

  10:          Log.Info(string.Format("ConnectSocket->Dns.GetHostEntry({0}) needed: {1}ms ",server, sp.ElapsedMilliseconds));

  11:          sp.Reset();


  13:          // Loop through the AddressList to obtain the supported AddressFamily. This is to avoid

  14:          // an exception that occurs when the host IP Address is not compatible with the address family

  15:          // (typical in the IPv6 case).

  16:          foreach (IPAddress address in hostEntry.AddressList)

  17:          {

  18:              sp.Start();

  19:              IPEndPoint ipe = new IPEndPoint(address, port);

  20:              Socket tempSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

  21:              tempSocket.ReceiveTimeout = 1000;

  22:              tempSocket.SendTimeout = 1000;

  23:              // this is very important!!! Do not delete this.

  24:              tempSocket.NoDelay = true;


  26:              try

  27:              {

  28:                  tempSocket.Connect(ipe);

  29:                  #region Status Check

  30:                  if (tempSocket.Connected)

  31:                  {

  32:                      #region Connnected Section

  33:                      result = true;

  34:                      if (tempSocket != null)

  35:                      {

  36:                          try

  37:                          {

  38:                              tempSocket.Shutdown(SocketShutdown.Both);

  39:                              tempSocket.Close();

  40:                          }

  41:                          catch (Exception ex)

  42:                          {

  43:                              // do nothing - only release resources and don't let the system fuck up

  44:                          }

  45:                          finally

  46:                          {

  47:                              tempSocket = null;

  48:                          }

  49:                      }

  50:                      #endregion Connnected Section

  51:                      break;

  52:                  }

  53:                  else

  54:                  {

  55:                      continue;

  56:                  }

  57:                  #endregion End Status Check

  58:              }

  59:              catch (Exception ex)

  60:              {

  61:                  string title = string.Format("Could not connect to server:{0}:{1} -  " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace, server, port);

  62:                  Log.Info(title);

  63:                  Log.Fatal(title);

  64:                  result = false;

  65:              }


  67:              sp.Stop();

  68:              Log.Info(string.Format("ConnectSocket->hostEntry.AddressList({0}) needed: {1}ms to connect to server ", ipe.Address.ToString(), sp.ElapsedMilliseconds));

  69:              sp.Reset();

  70:          }

  71:          return result;

  72:      }

Wednesday, August 13, 2008

Visual Studio 2008 and .NET Framework 3.5 Service Pack 1

The next service pack is finally available. If you are using .NET 3.5, or want to use any of the new features that we have been talking about being added in this service pack, I’d strongly recommend you upgrade to this. You can download it here.

So what are the new features in this, well for a Service Pack, quite a lot. Check them all out:
ASP.NET Dynamic Data, which provides a rich scaffolding framework that enables rapid data driven development without writing code, and a new addition to ASP.NET AJAX that provides support for managing browser history (back button support). For more information, see What’s New in ASP.NET and Web Development.

Core improvements to the CLR (common language runtime) that include better layout of .NET Framework native images, opting out of strong-name verification for fully trusted assemblies, improved application startup performance, better generated code that improves end-to-end application execution time, and opting managed code to run in ASLR (Address Space Layout Randomization) mode if supported by the operating system. Additionally, managed applications that are opened from network shares have the same behavior as native applications by running with full trust.

Performance improvements to WPF (Windows Presentation Foundation), including a faster startup time and improved performance for Bitmap effects. Additional functionality for WPF includes better support for line of business applications, native splash screen support, DirectX pixel shader support, and the new WebBrowser control.

ClickOnce application publishers can decide to opt out of signing and hashing as appropriate for their scenarios, developers can programmatically install ClickOnce applications that display a customized branding, and ClickOnce error dialog boxes support links to application-specific support sites on the Web.

The Entity Framework is an evolution of the existing suite of ADO.NET data access technologies. The Entity Framework enables developers to program against relational databases in according to application-specific domain models instead of the underlying database models. For more information, see Getting Started with the Entity Framework. The Entity Framework introduces some additional features, including support for new SQL Server 2008 types, default graph serialization of Entities, and the Entity Data Source. This release of the Entity Framework supports the new date and file stream capabilities in SQL Server 2008. The graph serialization work helps developers who want to build Windows Communication Foundation (WCF) services that model full graphs as data contracts. The Entity Data Source provides a traditional data source experience for ASP.NET Web application builders who want to work with the Entity Framework.

LINQ to SQL includes new support for the new date and file stream capabilities in SQL Server 2008.

The ADO.NET Data Services Framework consists of a combination of patterns and libraries, which enable data to be exposed as a flexible REST (Representational State Transfer)-based data service that can be consumed by Web clients in a corporate network or across the Internet.

The ADO.NET Data Services Framework makes data service creation over any data source. A conceptual view model of the underlying storage schema can easily be exposed through rich integration with the ADO.NET Entity Framework. Services created by using the ADO.NET Data Services Framework, and also compatible Windows Live ( services, can be easily accessed from any platform. For client applications that are running on Microsoft platforms, a set of client libraries are provided to make interaction with data services simple. For example, .NET Framework-based clients can use LINQ to query data services and a simple .NET Framework object layer to update data in the service.

Windows Communication Foundation now makes the DataContract Serializer easier to use by providing improved interoperability support, enhancing the debugging experience in partial trust scenarios, and extending syndication protocol support for wider usage in Web 2.0 applications.

The .NET Framework Data Provider for SQL Server (SqlClient) adds new support for file stream and sparse column capabilities in SQL Server 2008.
As for Visual Studio 2008, the Service Pack can be found here.
The following technologies have been tested and verified to work with SP1:
Silverlight 2 SDK Beta 2 & Silverlight Tools Beta 2. (If Silverlight Tools Beta 2 is already installed, you must upgrade it after you install Visual Studio 2008 SP1. To upgrade, use the installer on the Silverlight Tools Beta 2 page on the Microsoft Download Center Web site.)

  • MVC Preview Release #3
  • ASP.NET Extensions/Dynamic Data Preview
  • VC 2008 Feature Pack
  • VB PowerPack Controls (2.0 & 3.0)
  • Expression Studio 2 (RTM)
  • SQL Server 2008
  • .NET Framework 3.5 SDK
  • XSLT Profiler
  • VSTA 2.0 SDK
  • Visual Studio 2008 SDK
If you encounter issues installing SP1, uninstall technologies and/or development add-ins not listed above, and then try SP1 Setup again.

Windows Command Line FIND instead of GREP

People have maybe heared of grep on linux boxes... today I wanted to do a small count for the appeareance on a windows box where we host a log file with 500k rows.

P:\>find /?Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

  • /V Displays all lines NOT containing the specified string.
  • /C Displays only the count of lines containing the string.
  • /N Displays line numbers with the displayed lines.
  • /I Ignores the case of characters when searching for the string.
  • /OFF[LINE] Do not skip files with offline attribute set.
  • "string" Specifies the text string to find.
  • [drive:][path]filename Specifies a file or files to search.

If a path is not specified, FIND searches the text typed at the promptor piped from another command.

update: otherwise you can also use qgrep:


in general usability means the following

  • the system is easy to use and re-use
  • the system can be used efficiency
  • small amount of bugs / failures
  • users are happy with software

but think also about factors like

  1. Effectiveness - customer can find anything they like to.
  2. Efficiency - data can be find easily and fast.
  3. Satisfaction - customers are satisfied of your application and they come again and again

this has been translated from the following website: I absolutly aggree with above terms if they really do and life this terms I don't know.

How to find readable time difference bettween Oracle date types?

It is not crucial, but it is cool. This way you can find time date/time difference nicely. its very cool :-)

lpad(EXTRACT(HOUR FROM(dend_date - dstart_date) DAY TO SECOND),2,’0′) ‘ hour ‘ lpad(EXTRACT(MINUTE FROM(dend_date - dstart_date) DAY TO SECOND),2,’0′) ‘ minute ‘ lpad(EXTRACT(SECOND FROM(dend_date - dstart_date) DAY TO SECOND),2,’0′) ‘ second ‘ “Interval”FROM process_logorder by dstart_date desc;

ref::Oracle® Database SQL Reference10g Release 2 (10.2)B14200-02

thanks to:

Tuesday, August 12, 2008

Project phases

Preparation phase

Understand problems even if you need to request additional meetings for this. there is always somebody who can explain you details. creation of a basic to make decisions (Date, Budget, Environment, etc.). it will help all team members if you have a small model with a term overview - so everybody talks about the same. Try to identify risks and create a ranking of them - I use usually a range of 1 - 5. Each risk will be rated and it makes sense to discuss them with other people in your team.

Design phase

create all available use cases for your application. explain different use cases with 2 / 3 simple sentences. at this stage you start with architectural questions for system and environments. i suggest you start with a small front-end prototype which you can present your end users. you gone receive tons of feedback's.

Creation phase

start up with your development were you firstly describe your use cases deep enough that you able to develop unit tests and think about using aspect programming.

Entry phase

create presentations for the software - best case is if customers / target clients already know about what you are gone talk then we have integrated them deep enough into previous phases. The entry phases are usually very stressful and harm business incoming therefore don't forget: as better you prepare yourself as easier it gone be!

Important principles of agile projects


trust to solve problems tomorrow once they appear tomorrow. Feel free to come up with your concerns about actual problems today on a constructive way - do it before somebody else does it.


arrange face2face meetings - project members which meet they feel more comfortable to work together. Any problem is important to solve - communication problems are most important to solve.


force acceptance tests of your target clients, make reviews with other team members to receive feedback's about possible better solutions.


search for the simplest solution to solve your problem - exactly to solve upcoming problem. For 5 different problems think about 5 simple solutions instead one very complex solution. next time you know enough about the problem to solve all them together in one very simple solution.

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: Its free and easy to use, we provide all sources at codeplex.

Facebook Badge