Scenario:
You've been working with no problems probably in VS2008 on web app written on .net 2 or .net 3.5 or .net 3.5 sp1 and then you try running on a machine with windows 7 or vista running IIS7 and you get this error message...
Simples. It's comes of running your .Net 2 (you did know that a .Net 3.5 app actually runs on .Net 2 didn't you?) app under .Net 4. Fix it by changing the app pool for your web app to the pre-defined "Classic .Net App Pool", which runs .Net framework 3

Tag: .net
Bob Martin’s eliminate boolean arguments tip – an example
I don't always agree with Bob Martin's Clean Code Tip #12: Eliminate Boolean Arguments - probably because the mathematician in me believes that there are such things as functions of a boolean value - but I came across an example in a WinForms app today where I'd apply it.
[csharp]
void FindApplicant(int id)
{
processUIChange(true);
applicant= getTheApplicantFromDataLayer(id);
processUIChange(false);
}
[/csharp]
turned out to mean:
[csharp]
void ProcessUI(bool processing)
{
if(processing)
{
this.Enabled=false;
}
else
{
... do a whole load of stuff
}
}
[/csharp]
which would have been easier to read as:
[csharp]
void FindApplicant(int id)
{
DisableUIWhileUpdating();
applicant= getTheApplicantFromDataLayer(id);
UpdateUIAfterDataChange();
}
void DisableUIWhileUpdating()
{
this.Enabled=false
}
void UpdateUIafterDataChange()
{
...do a whole load of stuff
}
[/csharp]
C# : To return a comma delimited list from an array or collection of strings
Don't:
[csharp]
var description = new StringBuilder("");
foreach (var item in productItems.Where(x => x.ItemType == type))
{
description.Append(item.Description + ", ");
}
return description.Remove(description.Length - 2, 2).ToString();
[/csharp]
Do:
[csharp]
return string.Join(", ", productItems.Where(x => x.ItemType == type).Select(x => x.Description).ToArray());
[/csharp]
because the first example fails when your collection has no elements.