c# - Specify assembly for namespace -
is there anyway specify assembly along namespace in c#?
for instance, if reference both presentationframework.aero
, presentationframework.luna
in project might notice both of them share same controls in same namespace different implementation.
take buttonchrome
example. exists in both assemblies under namespace microsoft.windows.themes
.
in xaml include assembly along namespace here it's no problem
xmlns:aerotheme="clr-namespace:microsoft.windows.themes;assembly=presentationframework.aero" xmlns:lunatheme="clr-namespace:microsoft.windows.themes;assembly=presentationframework.luna" <aerotheme:buttonchrome ../> <lunatheme:buttonchrome ../>
but in c# code behind can't find anyway create instance of buttonchrome
in presentationframework.aero
.
the following code gives me error cs0433 when compiling
using microsoft.windows.themes; // ... buttonchrome buttonchrome = new buttonchrome();
error cs0433: type 'microsoft.windows.themes.buttonchrome' exists in both
'c:\program files (x86)\reference assemblies\microsoft\framework.netframework\v4.0\profile\client\presentationframework.aero.dll'
and
'c:\program files (x86)\reference assemblies\microsoft\framework.netframework\v4.0\profile\client\presentationframework.luna.dll'
which understandable, compiler has no way of knowing buttonchrome
choose because haven't told it. can somehow?
you need specify alias assembly reference , import via alias:
extern alias thealias;
see properties window references.
suppose alias aero assembly "aero" , luna assembly "luna". work both types within same file follows:
extern alias aero; extern alias luna; using lunatheme=luna::microsoft.windows.themes; using aerotheme=aero::microsoft.windows.themes; ... var lunabuttonchrome = new lunatheme.buttonchrome(); var aerobuttonchrome = new aerotheme.buttonchrome();
see extern alias more info.
Comments
Post a Comment