I am facing the very same problem as in Type exists in 2 assemblies:
The type exists in both <ASSEMBLY1.dll> and <ASSEMBLY2.dll>
I have tried the most voted answer from the question however, I am still getting the error.
I believe it is because my setup is quite different from the question: I have two my projects ProjectA
and ProjectB
, each of those using completely different NuGet packages, that happen to use a dependencies/types with exactly same name but from different vendors (without vendor prefix!). Both of these projects are referenced in ProjectC
ProjectA
- Packages
-- UnrelatedPackage1
--- Dependency (VendorA)
ProjectB
- Packages
-- UnrelatedPackage2
--- Dependency (VendorB)
ProjectC
- Refences
-- ProjectA
-- ProjectB
Now, I would like to catch in ProjectC
's code an exception raised in ProjectA
's dependency :
try {
ProjectA.SomeClass.DoStuff();
}
catch (ExceptionFromDependency ex)
{ }
but I cannot since
The type ExceptionFromDependency exists in both <Dependency (VendorA)> and <Dependency (VendorB)>
I have added an alias projectb
to ProjectB
's reference in ProejctC
as recommended in the answer, but it did not fix the error - probably because the source is not the project itself but rather dependency of dependency.
How can I fix the error so I can catch the exception? I dont ever plan to use any types from 'Dependency (VendorB)', and I would prefer to contain its existence to the ProjectB
, if that offers simpler solution.