This is actually language compiler feature. You give references (/r switch in C# and VB compilers) to the compiler and it will scan all available classes with their namespaces in these references. That's how compilers can find out where particular class is defined.
Visual Studio has its own built-in way how to find which assemblies to give to the compilers as reference assemblies. You can check it out in the build logs.
Note that the same namespace can be implemented in multiple assemblies (e.g. System namespace in mscorlib.dll and System.dll).
-Karel