我有一个在IIS上运行的API站点。然后,我将解决方案从.NET Core 2.1升级到2.2,现在出现以下错误:
"ExceptionDetail": {
"Type": "System.InvalidOperationException",
"HResult": -2146233079,
"Message": "An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call.",
"Source": "Microsoft.EntityFrameworkCore.SqlServer",
"InnerException": {
"Data": {
"HelpLink.ProdName": "Microsoft SQL Server",
"HelpLink.EvtSrc": "MSSQLServer",
"HelpLink.EvtID": "10060",
"HelpLink.BaseHelpUrl": "http://go.microsoft.com/fwlink",
"HelpLink.LinkId": "20476"
},
"HResult": -2146232060,
"Message": "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)",
"Source": "Core .Net SqlClient Data Provider",
"InnerException": {
"HResult": -2147467259,
"Message": "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond",
"Source": null,
"NativeErrorCode": 10060,
"ErrorCode": -2147467259,
"Type": "System.ComponentModel.Win32Exception"
},
"Errors": [
{
"Source": "Core .Net SqlClient Data Provider",
"Number": 10060,
"State": 0,
"Class": 20,
"Server": "",
"Message": "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)",
"Procedure": null,
"LineNumber": 0
}
],
"ClientConnectionId": "00000000-0000-0000-0000-000000000000",
"Class": 20,
"LineNumber": 0,
"Number": 10060,
"Procedure": null,
"Server": "",
"State": 0,
"ErrorCode": -2146232060,
"Type": "System.Data.SqlClient.SqlException"
}
我恢复到原来的2.1代码,并且可以正常工作。我还发布了一个独立的解决方案,但仍然遇到相同的错误。我还设置了.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
;
我的服务项目引用了引用数据库项目的应用程序项目,以下是项目文件:
服务:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;IDE0021</NoWarn>
<OutputPath></OutputPath>
<DocumentationFile>obj\Debug\netcoreapp2.1\CaseManagement.Service.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Shared\netcoreapp2.1\**" />
<Content Remove="Shared\netcoreapp2.1\**" />
<EmbeddedResource Remove="Shared\netcoreapp2.1\**" />
<None Remove="Shared\netcoreapp2.1\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseManagement.Application\CaseManagement.Application.csproj" />
<ProjectReference Include="..\CaseManagement.Infrustructure.Log\CaseManagement.Infrastructure.Log.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.Development.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Production.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="appsettings.Staging.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="Properties\launchSettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
应用程序:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1701;1702;IDE0021;1591</NoWarn>
<DocumentationFile>obj\Debug\netcoreapp2.1\CaseManagement.Application.xml</DocumentationFile>
<OutputPath></OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\CaseManagement.Core\CaseManagement.Core.csproj" />
<ProjectReference Include="..\CaseManagement.Infrustructure.Database\CaseManagement.Infrastructure.Database.csproj" />
<ProjectReference Include="..\CaseManagement.Infrustructure.Log\CaseManagement.Infrastructure.Log.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc.Core">
<HintPath>..\..\..\..\..\..\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.core\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll</HintPath>
</Reference>
<Reference Include="Swashbuckle.AspNetCore.Annotations">
<HintPath>..\..\..\..\..\..\Users\dinua\.nuget\packages\swashbuckle.aspnetcore.annotations\4.0.1\lib\netstandard2.0\Swashbuckle.AspNetCore.Annotations.dll</HintPath>
</Reference>
<Reference Include="Swashbuckle.AspNetCore.Swagger">
<HintPath>..\..\..\..\..\..\Users\dinua\.nuget\packages\swashbuckle.aspnetcore.swagger\4.0.1\lib\netstandard2.0\Swashbuckle.AspNetCore.Swagger.dll</HintPath>
</Reference>
<Reference Include="Swashbuckle.AspNetCore.SwaggerGen">
<HintPath>..\..\..\..\..\..\Users\dinua\.nuget\packages\swashbuckle.aspnetcore.swaggergen\4.0.1\lib\netstandard2.0\Swashbuckle.AspNetCore.SwaggerGen.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
数据库:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Configurations>Debug;Release;Production</Configurations>
<AssemblyName>CaseManagement.Infrastructure.Database</AssemblyName>
<RootNamespace>CaseManagement.Infrastructure.Database</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Repo\Shared\" />
<Folder Include="Sql\StoredProcedures\" />
<Folder Include="Sql\Tables\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseManagement.Infrustructure.Log\CaseManagement.Infrastructure.Log.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>System</HintPath>
</Reference>
</ItemGroup>
</Project>
不确定我还能做什么。