views:

1899

answers:

5

Given an instance of System.Reflection.Assembly.

+11  A: 

Not possible. Nothing specifies a "Root" namespace. The default namespace in the options is a visual studio thing, not a .net thing

Darren Kopp
+5  A: 

There could be any number of namespaces in a given assembly, and nothing requires them to all start from a common root. The best you could do would be to reflect over all the types in an assembly and build up a list of unique namespaces contained therein.

Jason Diller
+2  A: 

Assemblies don't necessarily have a root namespace. Namespaces and Assemblies are orthogonal.

What you may be looking for instead, is to find a type within that Assembly, and then find out what its namespace is.

You should be able to accomplish this by using the GetExportedTypes() member and then using the Namespace property from one of the returned Type handles.

Again though, no guarantees all the types are in the same namespace (or even in the same namespace hierarchy).

therealhoff
A: 

Get Types gives you a list of Type objects defined in the assembly. That object has a namespace property. Remember that an assembly can have multiple namespaces.

Charles Graham
A: 

Namespaces have nothing to do with assemblies - any mapping between a namespace and the classes in an assembly is purely due to a naming convention (or coincidence).

Michael Burr