dotnet核心3上缺少SqlException吗?

问题描述 投票:0回答:1

我在dotnet core 2.2上有一个C#代码,看起来像这样:

using System.Data.SqlClient;
// ...
if (e.InnerException != null && e.InnerException is SqlException && e.InnerException.Message.Contains("Cannot insert duplicate key row"))

我将dotnet核心版本升级到了版本3。

现在我收到此错误消息(编译时::)>

The type name 'SqlException' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=4.6.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

我用类视图对其进行了检查,它的外观看起来好像所请求的文件(SqlException)不存在(System.Data.SqlClient)。

此文件的替换项是什么?

我在dotnet core 2.2上有一个C#代码,如下所示:using System.Data.SqlClient; // ... if(e.InnerException!= null && e.InnerException是SqlException && e.InnerException ....

c# .net-core
1个回答
0
投票

解决方案

© www.soinside.com 2019 - 2024. All rights reserved.