Tool: Microsoft Moles Framework for Visual Studio 2010
If your machine has higher .Net framework installed (eg, 4.5) while your project is built targetting lower .Net framework (eg, 3.5), Moles framework will throw this kind of error when generating the Mole assembly:
The type or namespace name 'AntiXssEncoder' does not exist in the namespace 'System.Web.Security.AntiXss' (are you missing an assembly reference?)
Resolution: Manually edit the “.moles” file to remove reference to higher version classes that doesn’t exist in the lower .Net framework.
But, how exactly do we know which namespaces to be excluded? Easiest is to just run the build on the test project, look at the (huge) list of the error description similar to the above. It tells you exactly which namespace that is missing. Now, you just need to be creative to convert the error list from Visual Studio into the xml nodes in the .moles file. My personal favorite is copy to Excel, use Text to Column feature (delimited, single quote), then unique filter the namespace values, use concatenate function to construct the required elements, copy to .moles file.
Just in case, remember to eyeball check the resulting .moles nodes to see if there is anything not supposed to be there. After all, the Visual Studio error window may throw different errors.