Udostępnij za pośrednictwem


How to bind to 2 (or more) versions of the same assembly - the C# extern alias

A question came up internally as to whether you could (easily) use 2 different versions of the same assembly from an application - the C# language has a feature called the "extern alias" that makes this a very simple thing to do.

https://msdn2.microsoft.com/en-us/library/ms173212.aspx

It can sometimes be necessary to reference two versions of assemblies that have the same fully-qualified type names, for example when you need to use two or more versions of an assembly in the same application. By using an external assembly alias, the namespaces from each assembly can be wrapped inside root-level namespaces named by the alias, allowing them to be used in the same file