Custom framework targeting in Visual Studio 2010
See the question and my original answer on StackOverflowI think Visual Studio first looks in the registry, notably in this key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework (or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework on 64-bit systems)
You'll find a bunch of interesting subkeys, some of them actually pointing to the program files\referenced assemblies folders.