CodeSmith is one of those tools that I only pull out every now and then, but when I do it really comes in handy. Since my uses of CodeSmith are fairly limited I find that the freeware version of CodeSmith meets my needs just fine.
Category: Archive
Software Design Tip of the Fortnight: Tip #1
Database identifiers are not important… to your users. Sure database identifiers are important to the database, and they are important to your data access layer, but they are meaningless to the users of your application.
Software Design Tip of the Fortnight: Prelude
To design software is to attempt to understand the very logic that composes its parts. At best as software developers we make crude approximations as to the intentions of our applications. Even the most thorough requirements gathering cannot account for every last permutation, in much the same way that unit tests don’t guarantee that your system works.
.NET Extension Methods
Starting in .NET 3.5 is a feature called extension methods. Extension methods allow developers to extend classes with their own instance methods. This is a concept often called mix-ins in other languages.
Moving dasBlog to IIS7
Some of you may have noticed that several pages on this blog have been generating 404 errors for the past week or so. This was due, in part, to my recent migration to a Windows Server 2008 (IIS7) machine. Most of the blogs service interruption could have been avoided had I properly "test drove" the website after the migration. But in my haste I simply transferred the files to the remote server, hit the home page, and called it a night. Little did I know that most of the blogs content was unreachable.
Acquiring a Public Key Before Compiling
In the past I have talked about the The Wonders Of InternalsVisibleTo and how such a simple attribute allows for internal components to be shared between different assemblies, opening the door to greater code separation and dependency control. In that previous article I illustrated how you can use the tool that ships with Visual Studio to get the public key signature from one of your existing dlls.
Migrating to NHibernate 2.0
The NHibernate documentation is often very handy when working on NHibernate based project. I keep PDF copies of the documentation to NHibernate 1.0 and 1.2 on my hard drive as I never know when I will need to reference them. Unfortunately the NHibernate team seems to have dropped the ball in regards to version 2.0. Not only does the NHibernate website lack any documentation on version 2.0, the website acts as if version 2.0 hasn’t even been released yet. Unlike previous updates to the framework, version 2.0 represents a complete refactoring of the code base with many namespaces and objects either removed or renamed. Despite the lack of official documentation there are still several resources to help you migrate your existing NHibernate 1.2 application to NHibernate 2.0.
List of breaking changes
The NHibernate forum has a thread discussing the breaking changes between version 1.2 and an alpha pre-release of 2.0. For the complete list check out the forum, however here are the ones you will be most likely to face.
Problem: The NHibernate.Expression namespace no longer exists.
Overview: Most notable of the items formerly kept in this namespace was the Expression object used when creating ICriteria. Fortunately the object still existing in the NHibernate.Criterion namespace.
Solution: Replace all “using” statements to reflect the namespace change.
//using NHibernate.Expression; //this line is no longer needed in NH 2.0 using NHibernate.Criterion; //replace it with this line.
Problem: The nhibernate configuration section (most likely in your web.config or app.config) is no longer used.
Overview: NHibernate 2.0 no longer looks at the configuration section named nhibernate, instead it looks for a configuration section called hibernate-configuration (notice the lack of an “n” in hibernate). Moreover the configuration section wasn’t simply renamed, it bears and entirely different schema.
Solution: In short the entire configuration section is going to have to be reworked slightly.
For starters your configuration section declaration will have to change its name and type:
<configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" requirePermission="false"/> </configSections>
Source Control Is For Toddlers
You read that correct, source control is for toddlers. Not for toddlers to use, but rather to protect us from them. Surely the sole purpose of products such as Subversion, TFS, et. al. was to protect society from these pint sized keyboard loving terrors.
ASP.NET MVC Goes Beta
I somehow missed this one, but just yesterday ASP.NET MVC made it to Beta status. Justifying its own download page on the MSDN. I haven’t had a chance to read the release notes to see what all is new, as I am currently in process of uninstall Preview 5 to make way for this new release.
A Generic Error Occurred in GDI+
You know you’re doing good when your application crashes with an exception as detailed as “a generic error occurred in gdi+”. That is about as, well generic, as it gets :- )
In my particular case I was constructing an Image down in my DAO using the FromStream method, like so:
Image result; using (FileStream file = File.OpenRead(filename)) { result = Image.FromStream(file); file.Close(); } return result;
I was doing this so that I could know for a fact that the file was being disposed of properly. I didn’t want to have any orphaned file references locking up the file in case I later needed to delete it.
The problem was that up in my UI I was attempting to call the Save method on Image to dump its contents out to the ASP.NET response stream, like so:
img.Save(HttpContext.Response.OutputStream, ImageFormat.Jpeg);