I often debug  .NET Framework v 2.0 / v 4.0 code within windbg. In v 2.0 the main clr dll was called “mscorwks.dll” and in v 4.0 it is called “clr.dll”.  As many of you are aware , to load sos in v 2.0 we would have to enter “.loadby sos mscorwks” and in v 4.0 it would be “.loadby sos clr” . This was a pain for me. Came up with a script to automate loading sos based on clr version

[sourcecode]

!for_each_module .if(($sicmp( “@#ModuleName” , “mscorwks”) = 0) ) {.loadby sos mscorwks} .elsif ($sicmp( “@#ModuleName” , “clr”) = 0) {.loadby sos clr}

[/sourcecode]

You can take it up a notch by setting a break-point within clr based on the .NET Framework version

[sourcecode]

!for_each_module .if(($sicmp( “@#ModuleName” , “mscorwks”) = 0) ) {bp mscorwks!WKS::GCHeap::SuspendEE “.if (dwo(mscorwks!WKS::GCHeap::GcCondemnedGeneration)==2) {.echo start of gen 2}“} .elsif ($sicmp( “@#ModuleName” , “clr”) = 0) {bp clr!WKS::GCHeap::SuspendEE “.if (dwo(clr!WKS::GCHeap::GcCondemnedGeneration)==2) {.echo start of gen 2}“}

[/sourcecode]