I am developing a silverlight C# app, and I have added a reference to a Microsoft DLL and got the following message:
The type exists in both DLLs
Since I am using a control that is defined in both of the DLLs (one is associated with the SDK, the other one I added myself).
After did some research on the internet, I tried to make an alias of both of DLLs, and import them by using extern alias <alias_name>
. This approach solved some problem in the xaml.cs code behind, but did not really solve the problem in xaml. After I did this, Visual Studio complained that one of the controls (from the DLL I added) is not defined in the namespace.
So I am wondering if there is a way to specify namespace in XML using an alias?
Thank you.
Stackoverflow
MSDN
You just need to add a second alias to your assembly using comma delimiters.
eg
<Aliases>global,alias_name</Aliases>
XAML will use the global alias, and you can pick and choose in your classes.
.
If you need to use both assemblies in one place, I think this solution is the only one.
Basically, create two wrapper classes in separate namespaces in your own project for each required class, then reference the wrapper namespaces instead of the conflicting assemblies.
There is a good way if you use class from duplicated namespae in C# code (not in XAML) http://csc-technicalnotes.blogspot.ru/2009/07/type-exists-in-both-dlls.html
Use an external assembly alias. Specify "Aliases" property of DLL reference.
Specify alias in C# source code:
// Old way
using MyNamespace;
// New way
extern alias LegacyMyDLL;
using LegacyMyDLL.MyNamespace;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With