two different DLL with same namespace

There’s nothing special you need to do – just reference them and use the types. Namespaces can span accross several assemblies without problems, because they’re not really opaque types. A namespace is just a way of adding a common prefix to all the types it contains, allowing you to have multiple types of the same name under different namespaces. (The framework doesn’t see them as having the same names, because it sees the “fully qualified” name of everything – which has an alias and a namespace attached to the front of it.)

In the rare event that you reference 2 assemblies which have the same type names and the same namespaces (such as 2 different versions of the same dll) – you can distinguish which assembly to use for a given type using an alias. The default alias for all references is global, but you can specify your own alias for any assembly when you reference it (using a compiler switch – or just use the properties box in Visual Studio) – and have an extern alias <name> clause at the top of your code file where you use it – you would access the types from different assemblies with <name>::MyNamespace.Type

Leave a Comment