Runtime: System.Data.SqlDbType exists in both netstandard.dll and System.Data.SqlClient.dll

Created on 7 Mar 2017  路  9Comments  路  Source: dotnet/runtime

@billwert commented on Mon Mar 06 2017

This causes compile failures for apps using the type and the nuget package.

cc: @weshaggard


@weshaggard commented on Mon Mar 06 2017

You need to reference the latest version of System.Data.SqlDbType to fix this error.


@billwert commented on Mon Mar 06 2017

This project, with a reference to SqlDbType somewhere in the code, repros the problem:

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <NetStandardImplicitPackageVersion>2.0.0-beta-25106-01</NetStandardImplicitPackageVersion>
  </PropertyGroup>
  <ItemGroup>
  <PackageReference Include="System.Data.SqlClient">
    <Version>4.4.0-beta-25106-01</Version>
  </PackageReference>
  </ItemGroup>
</Project>

That's the latest NETStandard.Library as well as the latest System.Data.SqlClient.

From my project.assets.json:

   "System.Data.SqlClient/4.4.0-beta-25106-01": {
        "type": "package",
        "dependencies": {
          "Microsoft.NETCore.Platforms": "2.0.0-beta-25106-01",
          "NETStandard.Library": "1.6.1",
          "System.Data.Common": "4.3.0",
          "System.Diagnostics.DiagnosticSource": "4.4.0-beta-25106-01",
          "System.IO.Pipes": "4.3.0",
          "System.Net.NameResolution": "4.3.0",
          "System.Net.Security": "4.3.0",
          "System.Reflection.TypeExtensions": "4.3.0",
          "System.Security.Principal": "4.3.0",
          "System.Security.Principal.Windows": "4.4.0-beta-25106-01",
          "System.Text.Encoding.CodePages": "4.4.0-beta-25106-01",
          "System.Threading.Thread": "4.3.0",
          "System.Threading.ThreadPool": "4.3.0",
          "runtime.native.System.Data.SqlClient.sni": "4.3.0"
        },
area-System.Data.SqlClient

Most helpful comment

@DRAirey1 you need to reference the newest version of the System.Data.SqlClient package.

All 9 comments

We need to add netstandard2.0 ref asset to System.Data.SqlClient package.

cc @saurabh500

I'm running into this now. Why was this issue closed? What was the resolution?

@DRAirey1 you need to reference the newest version of the System.Data.SqlClient package.

I pulled down the 4.3.1 just this morning on a fresh .netstandard library project and got the errors. Then I pulled down pre-release 4.4.0-preview. Then I pulled down the System.Data.Common 4.3.0. None of these changes seems to have removed the conflict between the .netstandard library and the System.Data. What am I missing?

Yes would need to reference the latest prerelease for SqlClient https://www.nuget.org/packages/System.Data.SqlClient/4.4.0-preview2-25405-01. If that doesn't eliminate this issue for you can you please share your project.assets.json file (can be found in your obj dir) so I can have a look at the packages you are restoring in your project.

OK. It looks like the System.Data.Common was a bad idea. I started over again with a clean project, just installed the pre-release. It seems to be working now.

Sorry I forgot to mention that System.Data.Common is now part of netstandard2.0 so you should't need a reference to it, but the tooling should eliminate if you did reference it.

I'm on .NET Core 2.0 having solved the issue by installing System.Data.SqlClient.
Thank you @weshaggard for the solution and thanks @DRAirey1 for posting the issue.

Was this page helpful?
0 / 5 - 0 ratings