What use is the Aliases property of assembly references in Visual Studio 8

This is for “extern aliases”. Suppose you want to use two different types, both of which are called Foo.Bar (i.e. Bar in a namespace of Foo). The two types will be in different assemblies (by definition) – you use the property in VS to associate an alias with each reference, then you can do:

extern alias FirstAlias;
extern alias SecondAlias;

using FirstBar = FirstAlias::Foo.Bar;
using SecondBar = SecondAlias::Foo.Bar;

and then use FirstBar and SecondBar in your code.

So basically it’s an extra level of naming – and you shouldn’t use it unless you really, really have to. It will confuse a lot of people. Try to avoid getting into that situation in the first place – but be aware of this solution for those times where you just can’t avoid it.

Leave a Comment