Type Exists in 2 Assemblies

The type exists in both DLLs

Open up your project's References, right-click on the offender, and select Properties.

Sample Image

Change your Aliases to a custom name:

Sample Image

Then whenever you wish to use your offending reference in your code, simply insert this at the top of your file:

extern alias MyAlias;

Why do I get an error when this type exists in two assemblies even though I qualified the type?

This compiler error happens when there is 2 library referenced to the project, both having the same namespace/class name within, that you attempt to use.

If you cannot rename one, you need to set an alias for one.

Point of interest:

I found a worth to read answer in a related topic: using-directive solution (for inner classes) to prevent compilation error.

The type [Type] exists in both [Assembly1] and [netstandard 2.0 assembly]

Update: Visual Studio 2017 15.3 and the 2.0.0 SDK have been released. Use these versions to get rid of such conflicts.

This appears to be one of the build issues happening when using a mix of preview-tooling and "RTM" packages before all parts have been released.

To get the best support for 2.0.0 at the time of writing, do one of the following:

  • only use the same preview2 version of the nuget packages, the installed .NET Core SDK and the latest VS 2017 15.3 preview (15.3 Preview 7).

  • Use the latest VS 2017 15.3 Preview (Preview 7), install the 2.0.0 (not preview2) .NET Core Sdk from the CI build output at https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.0.0/dotnet-sdk-2.0.0-win-x64.exe (the same build output location is used by microsoft's 2.0.0 docker images)

The reason for this requirement is that the 2.0.0 SDK knows about these conflicts and trims the conflicting references (System.*.dll in this case) out of the projects.

The type type exists in both DLLs

This doesn't seem like a good idea no matter what, but change the namespaces and fully qualify your usages.

Otherwise, why don't you just reference one dll?

MVC3 Type exists in two different assemblies

Your conflict is in a folder named App_Code, which generates it's own DLL. Sounds like you have duplicate code in that folder with something referenced somewhere else. You could either remove that duplicate code and use the referenced assembly, or (if you need the code) rename the folder (like you stated in your comment).

I'd recommend you either remove the code or look to rename the duplicate code as it could cause confusion down the road.

Hope this helps!

Type exists in both error sharing project references and giving each project it's own DLL build of a library when building

Seemed to be related to Visual studio caching and how packages are managed so I reverted by source code to start over again. I uninstalled/re-installed nuget packages, manually added my own DLL's, re-built everything from scratch, and it finally worked.



Related Topics



Leave a reply



Submit