Reputation: 2347
I have a class MyClass under the namespace Phoenix in two different assemblies ClassLibrary1 and ClassLibrary2. ClassLibrary2 is reference in ClassLibrary1. Now in my ClassLibrary1 wherever I have made use of the MyClass type it gives me a warning of conflicts with imported types. How can I resolve this without suppressing the warning using pragma directive?
Upvotes: 1
Views: 2328
Reputation: 8182
Give an alias (other than the default 'global') to the ClassLibrary2
reference in the ClassLibrary1
project, by going into Properties on the reference itself.
This will get rid of the warning instantly in case you wanted to use the ClassLibrary1 version.
Now, whenever you want to access something from the ClassLibrary2 dll, you will need to place this on top of your class code:
extern alias <yourAliasName>;
using MyClassOther = yourAliasName::Phoenix.MyClass;
If you want to keep existing code that references other classes from ClassLibrary1
working, you can keep the global alias and just add another alias to the reference. This way, you will just need the above code on classes that actually use MyClass
. Then you will need to fully qualify the usage in (hopefully) a lot fewer cases.
Upvotes: 2