views:

78

answers:

2

I have two DLL file that they both have a same namespace but they have different functions and types. how can I references both DLLs in my Project and use their functions and types?

by the way. these two DLL have some functions and types with same name and different implementation and some unique functions and types

+7  A: 

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

Mark H
You can read about `extern alias` here: http://msdn.microsoft.com/en-us/library/ms173212.aspx
Porges
A: 

you can use the alias feature of the /reference (Import Metadata) (C# Compiler Options) compiler option to solve your problems, read from here for more details

Hiber