I’m currently developing a .NET Windows Service and am curious about how references vs. namespaces work on a high level. I come from a C++ background and am only familiar with statements like #include <…> etc. Thanks for the clarification.
I’m currently developing a .NET Windows Service and am curious about how references vs.
Share
A reference is simply a way to tell the compiler to look in the referenced assembly for types when trying to resolve them.
Now, namespaces are not tied to assemblies. Namespaces are a logical construct while assemblies are a physical construct.
This is why you see classes in .NET from the System namespace in mscorlib.dll, System.dll, System.Core.dll, etc, etc.
So while you can have tremendous overlap between the two, you should avoid leaking your namespace across too many assemblies.
I take a assembly-per-namespace approach (the assembly only has types from one namespace, assuming it is specialized), but your approach may vary.
Generally though, keep the namespace bleed small (or none at all) and you will generally be fine.