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

5

11

I cannot get Microsoft.EntityFrameworkCore 2.0 to work with NETStandard.Library 2.0

Error CS0433 The type 'AttributeUsageAttribute' exists in both 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Contrived.Model.Schema D:\Contrived\Contrived\Framework\Contrived.Model.Schema\Attributes\EntityColumnAttribute.cs

My .csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.0" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="NETStandard.Library" Version="2.0.0" />
  </ItemGroup>

</Project>

This also happens if i create a new solution and a netstandard 2.0 library then add entityframeworkcore 2.0

Error CS1703 Multiple assemblies with equivalent identity have been imported: 'D:\Users\maksymiuk_a.nuget\packages\netstandard.library\2.0.0\build\netstandard2.0\ref\System.Threading.Tasks.dll' and 'D:\Users\maksymiuk_a.nuget\packages\system.threading.tasks\4.3.0\ref\netstandard1.3\System.Threading.Tasks.dll'. Remove one of the duplicate references. ClassLibrary1 D:\Contrived\Contrived\ClassLibrary1\ClassLibrary1\CSC

Staley answered 13/8, 2017 at 16:5 Comment(5)
Which version of VS and the .net core SDK do you have installed? also, remove the reference update for NETStandard.Library, this needs to be handled implicitly by the SDK.Signification
Visual Studio Version 15.2 (26430.16) also where do i see the SDK version? and how do i remove the reference update?Staley
You need the latest 15.3 Preview for the 2.0.0 SDK to workSignification
Or wait a few days until the appropriate VS update is releasedSignification
just delete the <ItemGroup> containing the NETStandard.Library Update=".." declarationSignification
S
4

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:

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.

Signification answered 13/8, 2017 at 16:58 Comment(2)
Thank you, im sure this is the correct answer, as soon as i get it to work ill accept this oneStaley
Updated with links to the now officially released versions.Signification
M
2

This issue can still happen even with DOT NET Core 2+, and is caused when the packages you reference in your project depend on a different version of the same package, specifically same namespace.

There are 2.5 solutions that I know of:

1) If you control both packages, then update both to make sure they are using the same version of that dependency (or change the namespace of one of the versions of that dependency, like: Your.Thing.v3.Models)

2) If you can find one or both of those packages on an open source site like GitHub, you can download them and update them to use the same version of that dependency (or the namespace thing from option 1, above)

2.5) If you don't control or have access to the source of those packages, and I realize that this isn't really a solution... (hence the .5), then the last option is to stop using one of those packages.

If there's another way, I'd love to know about it.

Meitner answered 13/2, 2018 at 6:52 Comment(0)
S
0

Probably not the best idea out there, but try to remove the reference to System.Runtime manually by right-click on references and finding it there.

Spriggs answered 13/8, 2017 at 16:10 Comment(4)
if i go to reference manager -> assemblies -> framework, then it tell me No Framework assemblies were found on the machineStaley
What IDE are you using??Spriggs
Visual Studio 2017Staley
2.0.0 conflict resolution needs to be done by the 2.0.0 SDK and not manually - the 1.* / VS 2017 15.2 tooling has no chance of doing that by itself and it cannot be easily done manuallySignification
L
0

For me it worked to remove the reference to both assemblies and re-add them again.

Expand your project's References in the Solution Explorer --> Right click the faulty assembly -> Remove.

Then right click References -> Add Reference... -> check the boxes of the assemblies you just removed.

Then rebuild.

Lyndialyndon answered 18/4, 2018 at 10:52 Comment(0)
E
0

In my case I have added multiple reference in web.config file. after removing one of them resolve the issue and working perfectly under local IIS server also

Evidence answered 6/12, 2019 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.