Clean .Net program install package = ILMerge

I just had to post about this little tool ! I think all people who are busy in software development using .Net, should at least have a look at it ;).

What am I talking about, well, a small tool called ILMerge. It’s available from the research part of Microsoft. So what is it about ?

Best way to explain a tool is by giving an example : Imagine you have several .Net projects that, all of them, create separate dll’s ! This is not uncommon and you probably designed your projects this way, because they reflect some sort of internal business architecture… so no worries here. But on the other hand you probably also have some solutions that incorporate several projects, who have some kind of common link between them. So wouldn’t it be nice if you could get all those projects, that are linked one way or another, inside one dll instead of separated ones ?

Well with ILMerge you can accomplish this ! It will combine several input dll’s into one target dll or even better, combine an exe and several dll’s into just one exe ! Another example is to combine code dll’s together with their resource assemblies !

This procedure is of course only relevant for deployment of your software, so developers don’t have to perform this step and still can program with the complete original dll base ! But before packaging the software, it would be ideal to merge several dll’s to get a cleaner, smaller install package.

On a side note, I received a small update by Scott Guthrie, that there will be an ASPNet_Merge.exe MS Build task with the Visual Studio 2008 release !! But no ILMerge task yet…

Technorati tags: , , , , , ,

DateTime formatting the .Net way

Back in the ‘old’ days when we where using Visual Studio 6 and made our first Visual Basic programs, we had to rely on ‘good luck’ and ‘plumbing’ to get some tasks done !

What I mean to say is, that sometimes the software would have a mind of his own ! Some code just didn’t perform in the correct expected manner. And this wasn’t something you actually could have avoided, no the software had some flaws !

But with the arrival of Visual Studio .Net and the new programming languages like C#, this seemed a thing of the past ! Until now that is ! Because I have a small code example I would like to show you, that would seems very straightforward, but has me ‘bugged’ whole week.

The thing I’m trying to do, is cast a normal DateTime.Now to a Time format, but depending on the current user settings ( in the regional settings ). What would seem like an obvious thing to do… So here we go with our little experiment !

  • First set your regional settings correct : English ( US )

  • Then go to Customize and in the Time pane change the time to display using the 24 hours notation ( and loose the AM & PM )

  • Create a small console application and paste following code ( we are talking Visual Studio 2005 here )

// Expected : True, Actual : True
Console.WriteLine(Thread.CurrentThread.CurrentCulture.UseUserOverride.ToString());
// Expected : H:mm:ss, Actual : h:mm:ss
Console.WriteLine(Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern);
// Expected : H:mm:ss, Actual : h:mm:ss
Console.WriteLine(System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortTimePattern);
// Expected : 10/13/2006 13:31, Actual : 10/13/2006 01:31
Console.WriteLine(DateTime.Now.ToString("g"));
// Expected : 10/13/2006 13:31:28, Actual : 10/13/2006 13:31:28 !!!!!!
Console.WriteLine(DateTime.Now.ToString());
// Expected : 13:31, Actual : 01:31
Console.WriteLine(DateTime.Now.ToString("t"));
Console.ReadLine();

So as you can see, the DateTime.Now.ToString(“t”) option will NOT take into account the current user settings, found on the regional settings pane ! This is not something I would expect… I would just like my code to be as little dependent as possible. So I WANT to use the default DateTime formatting options and not having to wander about what the user chooses. It must be up to the user to get the right format he wants, I just want to be able to tell the program to give me the Time and not the complete DateTime.

After this little experiment, I searched further for any information, but got back empty handed.

The only document on MSDN that says something significant about DateTime and the regional settings can be found here. But it just states the things I would expect in my test and they just aren’t true.

After this set back I contacted Chris Sells Program Manager in the Distributed Systems Group at Microsoft, hoping maybe he could shed a little light on my issue ! To be honest this guy is amazing ;), knowing he’s probably swamped with work, he still managed to reply me in a very fast time frame ( thanks Chris ) !

The first thing Chris noticed was that I could get the good user settings information through the following code :

System.Globalization.DateTimeFormatInfo.CurrentInfo.FullDateTimePattern

But this wasn’t helping me much… the real problem is not getting the info about the DateTime format, but displaying it correctly using the default formatters in .Net ! So this info is a bonus, yes, but still I’m stuck !!

So for now I use a small work around, that I would love to delete as soon as possible, by reading out the users settings of the regional settings through the HKEY_CURRENT_USER in the registry ( \Control Panel\International ).

Chris will still check his huge background information repository 😉 and hopefully come back with some good news. But if ANYBODY knows how I can solve this ‘little’ problem, please help me out !

UPDATE : well Chris got back to me on this problem… he submitted my question on some community and he got an answer from Michael Kaplan !
It seems he has answered this question before !! Take a look here for more info on the solution.

In short : “A lot of the confusion is due to the fact that the .NET Framework has two time formats (long and short) while Windows only has one time format (long) which can optionally be truncated in GetTimeFormat.” And : “So the answer to the original customer inquiry, to wit: “The main issue is that I don’t understand why/when .Net uses the user overrides of the Regional Settings” is that only one of the settings in .NET directly relates to the one in Windows, even though they both look like they ought to….”

Currently listening to : Autoharp – Hooverphonic ( The Magnificent Tree )
Del.icio.us tags: , , ,

Football – stop saying soccer

Ok this post is going to be a bit odd… it involves soccer !!

Not that I’m that big of a fan of the game, although I played it myself for most of my current life, but this little thing just has me hooked.

There is a social network game online, called Hattrick and it is created around the most popular sport in the world soccer. The objective is quit straightforward : manage your own team !

The setup is simple, first you create a free account on Hattrick and after a day you get a team assigned ! You’ll be placed in a small competition and will be able to play against the other teams inside your competition.

Sounds easy and it is, but what strikes my is the level of detail you have at your disposal to manage all kinds of settings ! A small list of things to do :

  • Assign a coach
  • Choose training schemas
  • Hire other staff ( like a doctor )
  • Buy and sell players at a special eBay like trading place
  • Manage the players on the field, choose the right positions and follow their progress
  • Choose different setup formats for each league game
  • Expand your home stadium

And the list just goes on and on ! After reading this you’ll think it to be overwhelming and impossible to manage, but it really is just easy…

What I find even more extraordinary is the fact that everything just runs very smooth and seems to be programmed with the old ASP technology ! You can even follow the games in real time, through text messaging !

Damn I wish I could create something like that !!

Currently listening to: Stereo MC’sWe Belong in This World Together
Del.icio.us tags: , , ,

Project maintenance

Let me post something that involves a bit of the Web 2.0 hype 🙂 !

Today several websites offer some kind of free ‘social’ service, that can be used by the general public. Very nice things are available for the web-generation !! Some examples :

* Grou.ps
* Del.icio.us
* Google calendar

The list is long…

But there is one GREAT drawback with all this Web 2.0 stuff : it are actually all programming projects, that need to be maintained, tested and if needed updated or enhanced !!
This means that people need to be involved and keep track of possible bugs ! This takes time and effort… so for some ‘free’ ‘opensource’ websites, this can be a pain in the a**, if not impossible !

On the other hand, some guys are doing a fine job and let me put some of these guys in front and give them the credit they deserve ! It seems a coincidence, but last week I had several problems with serveral online services/websites.
First thing to do in such an event is search the site for some way to contact the webadmin, programmer or support. If you can’t find a contact, maybe there are other options, like online support forums…

But the best thing is presenting the problem to the original owner.

Let us begin with : Grou.ps, they offer a great tool to ‘group’ people together in a ( pun intended ) group ! One of the main features is the option to add locations using Google maps and here I had an issue ! I live in Belgium and only recently Google maps was updated with a street level detail of our country ( since version 2.x ), but Grou.ps isn’t yet upgraded ! So I posted the problem on the website and voila even after one day I got feedback, stating they are looking into this and are aware they need to upgrade the Google maps software plugin ! The even created an internal bug ticket, how sweet !!

Secondly, I use PMetrics on my blog to keep statistics of the users that come and read the feeds ! They had an upgrade of their software so that it is usable as a Sidebar Widget in WordPress, a cool feature ! But when I switch on this feature, the statistics fail and aren’t visible anymore for the public… also here I posted an error report on the public forum. Again one day after the post I received a personal message with detailed questions to help the developer to search and solve the problem. Even a response was posted back on the forum !!

Last but not least, I follow several Wing Chun ( Wing Tsun, Wing Tsjun ) sites to read about this fine martial arts sport… and there is one that comes out a bit special : the Wing Chun Archive. It states that the site is a ‘collection’ of all information, schools, peoples and media about the art ! Of course this can’t be achieved without the help of a supporting audiance ! So I gave it a test and used the ‘suggestion’ form to add a new Cantonese translation… for the third time in a row, I got a response the next day !! The new phrase was added and the webadmin gave me a feedback on the update… The Wing Chun stance Yee Gee Kim Yeung Ma was added.

Well to be honest, I was very suprised by the hard work and commitment I got from these websites… this makes those services all the more enjoyable and I hope they keep up the good work !

Update: Seems Michel doesn’t like the Web deux point zero hype ;), well all I can tell is that he is right in stating that the ‘real’ web 2.0 isn’t new… But today people are more focused on the subject and try to integrate more, that gives us great new services !