extern alias (C# Reference)

Blog - Programming

User Rating: / 0
PoorBest 

Source: MSDN

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.

 

NoteNote

The extern keyword is also used as a method modifier, declaring a method written in unmanaged code.

To reference two assemblies with the same fully-qualified type names, an alias must be specified on the command line, as follows:

/r:GridV1=grid.dll

/r:GridV2=grid20.dll

This creates the external aliases GridV1 and GridV2. To use these aliases from within a program, reference them using the extern keyword. For example:

extern alias GridV1;

extern alias GridV2;

Each extern alias declaration introduces an additional root-level namespace that parallels (but does not lie within) the global namespace. Thus types from each assembly can be referred to without ambiguity using their fully qualified name, rooted in the appropriate namespace-alias

In the above example, GridV1::Grid would be the grid control from grid.dll, and GridV2::Grid would be the grid control from grid20.dll.



Add this page to your favorite Social Bookmarking websites

Add comment


Security code
Refresh

Idioms

  • Doing nothing is doing ill. (Nhàn cư vi bất thiện)
  • Diamond cut diamond (Vỏ quýt dày móng tay nhọn)

Who's online

We have 34 guests online

Location

 38.107.179.218
 38.107.179.218
Search Bot
 unknown unkno

Relax

Site Ranking


Increase your website traffic with Attracta.com

Quick Search

This Day in History

Poll

What is your current operating system?
 

Weather

Newsletter

Copyright © 2012 Thong D. Nguyen. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.