Update to .NET 4.0 and fix compilation issues.