Wednesday, January 28, 2009

SDF (Compact sql database) with .NET 3.5SP1 Buggy with Entity Framework

I just can't believe Microsoft will ship this technology with such major bugs within it. If you are looking into SDF files with support of entity framework, you might want to look into the major bugs they are having. For example, you will not be able to use a string variable in a compare operation with a LINQ statement. Sounds basic, but still it does not work. Look at the blob on this bug

http://social.msdn.microsoft.com/forums/en-US/sqlce/thread/b6bac277-cf66-4c74-a0b3-e48abedbd161/

I wonder if Microsoft forgot to unit-test this stuff before shipping.

Thursday, January 8, 2009

How to find an avaiable TCP port

This simple method will return the next avaiable TCP port



      private static int GetAvaiablePort()
{
IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
socket.Bind(endPoint);
IPEndPoint local = (IPEndPoint)socket.LocalEndPoint;
return local.Port;
}
}