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.
So needless to say I was disappointed when I started CodeSmith to see an error message informing me that it required .NET 1.1 to operate. The sensible thing would have been to install .NET 1.1, but that seemed like a lot of hassle since I (otherwise) had no use for .NET 1.1. Knowing that the application would have attempted to execute under .NET 2.0 in the absence of 1.1 unless it was explicitly instructed not to, I set out to find what was stopping it from running.
I first turned to the CodeSmith.exe.config file where I saw:
<startup> <supportedRuntime version="v1.1.4322" /> <supportedRuntime version="v1.0.3705" /> <requiredRuntime version="v1.0.3705" /> </startup>
From the above it was easy to see why the program refused to run. It was configured to only run under specific versions of the .NET runtime. By commenting out that configuration element and saving the config file I was able to force CodeSmith 2.6 to run under .NET 2.0.
In addition to just getting it to run this has the added benefit of allowing you to use .NET 2.0 features (like generics) from your CodeSmith templates. Considering that the application was never intended to run under .NET 2.0, there is the distinct possibility of crashes, and otherwise erroneous behavior. And while I have never experienced any problems, I wouldn’t completely dismiss why the compatibility configurations might have been present in the first place.