Converting .NET DLLs to 4.0 by hand is too much work
One of the blockers for upgrading a project to .NET 4.0 is that your old .NET 2.0/3.0/3.5 DLLs will have some difficulty running in .NET 4.0. I’m far too lazy to track down all the 3rd party DLLs like Moq or log4net, download the source, switch the project to 4.0, then recompile the DLL.
Hackery makes life easier
Instead of doing this, for a lot of DLLs, you can get away with roundtripping the DLL using ildasm/ilasm; the only tricky part is changing the assembly references so that they point to .NET 4.0 DLLs instead of the old and busted 2.0
The good news is, I’ve written an IronRuby (or MRI, or JRuby, etc) script to handle this automagically. Here’s how to use it:
How to use:
- Download IronRuby from CodePlex (You can use the .NET 4.0 release too, doesn’t matter), and copy it to
- Download dotnet4ify_dll.rb from my website
- Launch the VS Command Prompt (2010) – don’t launch the 2008 one by accident!
ir dotnet4ify_dll.rb C:\path\to\an\old\assembly.dll .\v4dlls\assembly.dll
- While I’ve tested this on some pretty complex DLLs (DotNetOpenAuth, ParallelFramework_3_5.dll), it’s definitely in the “Works on My Machine” class of software; in particular, C++/CLI DLLs will probably not work. Embedded resources do still get embedded in the new binary
- .NET Assemblies get upset if you rename them, so you can’t do something like “ir dotnet4ify_dll.rb foo.dll foo_v4.dll” – just put all your v4 assemblies in a separate directory
Worked for me, but I make no guarantees it won’t replace DLLs with a lolcat