使用.NET Core 1.0时出现以下编译错误:
“找不到类型或 namespace 名称'DataException'(是否缺少using指令或程序集引用?)”,代码:CS0246。
project.json
{
"name": "Dna.Net.Core",
"version": "1.0.0-*",
"dependencies": {
"Autofac": "4.1.0",
"NETStandard.Library": "1.6.0",
"System.Data.SqlClient": "4.1.0",
"System.Runtime": "4.1.0",
"System.Runtime.Serialization.Formatters": "4.0.0-rc3-24212-01",
"System.Runtime.Serialization.Primitives": "4.1.1"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
corefx: System.Data.SqlClient
48 <Compile Include="System\Data\DataException.cs" />
IDataExceptionMessageHandler.cs
using Dna.Net.Core.Common;
using System.Data;
namespace Dna.Net.Core.Exceptions
{
public partial interface IDataExceptionMessageHandler
{
CustomMessage Execute(DataException exception);
CustomMessage ParseMessage(DataException exception, CustomMessage customMessage);
void LogException(string message);
}
}
.NET Core 1.0是否支持System \ Data \ DataException.cs?
最佳答案
该文件在那里,但没有DataException类-https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/src/System/Data/DataException.cs
它不支持。
关于.net-core - 找不到类型或 namespace 名称'DataException',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39185879/