January 2010 - Posts

The question came from my son… and he was right. There’s something wrong with it.


I just got rid of all old DVDs with interactive learning. Funny how fast technology becomes outdated, yet principles never change. I also stopped using interactive courses long time ago, as they become a bit useless – a contemporary tech. books, blogs and webinars are definitely enough to get your feet wet in new technologies. 


As a part of the build script I tend to generate AssemblyInfo.cs in order to inject assembly information dynamically, such as version, name, etc. One gotcha I ran into lately, is when you have internals that are testable and need to generate that information from NAnt as well.

Normally, the code in AssemblyInfo.cs wood look like this:

[assembly: InternalsVisibleTo("Project.Test")]

NAnt fails. Reason - NAnt is requires full class name, which is InternalsVisibleToAttribute, so that the line of code showed above looks like this:

[assembly: InternalsVisibleToAttribute("Project.Test")]

Each time we use NHibernate, we have to share production and semi-production code for NHibernate SessionFactory. Production code is the portion that is actually responsible to generate the SessionFactory on startup. Semi-production code, is the code that generates SessionFactory for purpose of schema extraction (SQL statements we use to generate DB). This time around, the smell had to be removed. Having identical code duplicated not only risky, but also becomes intolerable once it grows beyond a single line. This is our new SessionBuilder, that leverages the same code to generate SessionFactory for run-time purpose and schema generation at “design” time.

private static ISessionFactory sessionFactory;
private ISession session;
public ISession GetSession()
  if (session == null)
    session = sessionFactory.OpenSession();
  return session;
public void CloseSession()
  if (session.IsNull())
  session = null;
private static void Initialize()
  if (sessionFactory.IsNull())
    sessionFactory = GetProjectNHibernateConfiguraton().BuildSessionFactory();
private static FluentConfiguration GetProjectNHibernateConfiguraton()
  var nhibernateConfiguration = new Configuration().Configure();
  var model = AutoMap.AssemblyOf<Entity>().IgnoreBase<Entity>()
    .Where(type => typeof (Entity).IsAssignableFrom(type))
  return Fluently.Configure(nhibernateConfiguration)
    .Mappings(mappingConfiguration => mappingConfiguration.AutoMappings.Add(model));
#region Manually used to generate DB schema SQL scripts

internal static string DROP_SCHEMA_SQL_SCRIPT_NAME =

new FileInfo(Path.Combine(Path.GetTempPath(), "Schema_Drop.sql")).FullName;

internal static string CREATE_SCHEMA_SQL_SCRIPT_NAME =

new FileInfo(Path.Combine(Path.GetTempPath(), "Schema_Create.sql")).FullName;

/// <summary>Use TestDriven.Net to run this method as a test to generate SQL scripts and their files.</summary>
internal static void Generate_Database_Schema_and_Create_SQL_script_files()
private static void SchemaGenerator(Configuration configuration)
  var schemaExport = new SchemaExport(configuration);
  schemaExport.SetOutputFile(DROP_SCHEMA_SQL_SCRIPT_NAME).Drop(true, false);
  schemaExport.SetOutputFile(CREATE_SCHEMA_SQL_SCRIPT_NAME).Create(true, false);

Region represents the “design-time” code. And I was using Fluent NHibernate with auto-mapping to generate the entities.

We got two good developers applied and accepted to the company from what it looks through my blog. I have posted about 2 weeks ago that we are looking for developers. This is great! We need more people. Same call is still active.

Oh, and it tells me someone out there is actually reading the blog :)

I like the idea of being able to copy something and paste it on the net. It’s handy, no registration is required, and it’s temporary, just as clipboard supposed to be.

I use imbPlace.com for images. Does anyone knows similar service for C# code snippets?

Another case of creativity that makes you smile.

And well, for every good start, there’s more to come :D

Looking for help. I am trying to select a good .NET obfuscator tool that has to be:

  1. Free
  2. Supported (still developed)
  3. Work well with command line (for automated build script)
  4. Be flexible enough (configurable for options)

Right now Babel Obfuscator looks good. My decision was based on analysis of possible tools listed on this wiki. In case you have some input that can help me to do a better choice, feel free to leave comments. Appreciated.

HttpListener provided with .NET version 2.0 and up allow to build a custom HTTP server based application without need to have IIS installed on machine. This can be handy in some scenarios, where IIS cannot fit it. HttpListener can handle normal HTTP traffic, as well as HTTPS (secure). Once details that is hard to find online, is the fact that there’s a conflict between IIS and HttpListener to listen simultaneously to port 443 despite different prefixes being used. After digging for a while, the answer was found. Apparently, Windows 2003 is coming with IIS 6.0 and Windows XP comes with IIS 5.1. That little details does the difference (underlying implementation in HTTP.SYS looks like).

Hopefully this saves time to those that ran into case.


This is personal content post.

Yesterday I celebrated my birthday. My son, who’s almost six and is discovering the beauty of math, asked me how old I will be this birthday. On what I decided to puzzle him a bit and answered “two in power of five” (he knows plus, minus, multiplication and that’s it). To my surprise, he had an answer figured for himself quite fast. “Dad, so you are really young! 25 only, cool.”

I never had a chance to reflect back, but looking at things now, Liam and Liz were the best gifts I got from my wife.

More Posts Next page »