我已将 .NET Core 2.1 Web 应用程序升级到 .NET 7。
该应用程序在 Visual Studio 2022 上运行良好。
当我通过 Azure DevOps 管道将其部署到 Azure 时,出现以下错误:
HTTP 错误 500.32 - ANCM 无法加载 dll
此问题的常见解决方案:
该应用程序的发布位数可能与 w3wp.exe/iisexpress.exe 运行时的位数不同。
故障排除步骤:
检查系统事件日志中的错误消息 启用记录应用程序进程的标准输出消息 将调试器附加到应用程序进程并检查 有关更多信息,请访问:https://{此站点名称}.scm.azurewebsites.net/ detectors 和 https://go.microsoft.com/fwlink/?LinkID=2028526
如果我只是将以下行添加到项目文件中,它在 Azure 上运行良好
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
我从专家那里了解到,InProcess 的性能比 OutofProcess 更好,因此希望使用 InProcess 解决该问题。
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<AssemblyName>ABC.Web</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>ABC.Web</PackageId>
<UserSecretsId>2d8de5d0-adb3-41a5-90a7-299d114b1dda</UserSecretsId>
<Configurations>Debug;Release;Staging</Configurations>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Remove="node_modules;jspm_packages" />
<Content Remove="web.config" />
<None Remove="Properties\PublishProfiles\staging.pubxml" />
<None Include="App.config" />
<None Include="web.config" />
<None Update="wwwroot\**\*;**.cshtml;Views\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ABC.ApplicationServices.Core\ABC.ApplicationServices.Core.csproj" />
<ProjectReference Include="..\ABC.Common.Core\ABC.Common.Core.csproj" />
<ProjectReference Include="..\ABC.Data.Core\ABC.Data.Core.csproj" />
<ProjectReference Include="..\ABC.Domain.Core\ABC.Domain.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="Elmah.Io.AspNetCore" Version="5.0.56" />
<PackageReference Include="EPPlus.Core" Version="1.5.4" />
<PackageReference Include="EvoHtmlToPdf_NetCore_Client" Version="7.5.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="Hangfire.SqlServer" Version="1.8.5" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="PDF.Core" Version="2020.0.0" />
<PackageReference Include="RestSharp" Version="106.3.1" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="1.0.0-beta0009" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.10" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<Content Update="Views\EmailTemplates\ReleasedEmail.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\PDFTemplates\ReportTemplates\SubmissionSummary.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\PDFTemplates\ReportTemplates\STSubmissionSummary.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\PDFTemplates\ScheduleRunSheet.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\Shared\ArchivedAModal.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\Shared\Archived.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\Shared\ExpiredLink.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Views\EmailTemplates\RequestCancellation.cshtml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Update="Views\EmailTemplates\RequestChanged.cshtml">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="Views\Home\" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="PUBLISH\app.config" />
<_ContentIncludedByDefault Remove="PUBLISH\ABC.Web.dll.config" />
<_ContentIncludedByDefault Remove="PUBLISH\web.config" />
<_ContentIncludedByDefault Remove="PUBLISH\appsettings.json" />
<_ContentIncludedByDefault Remove="PUBLISH\appsettings.Production.json" />
<_ContentIncludedByDefault Remove="PUBLISH\appsettings.Staging.json" />
<_ContentIncludedByDefault Remove="PUBLISH\ABC.Web.deps.json" />
<_ContentIncludedByDefault Remove="PUBLISH\ABC.Web.runtimeconfig.json" />
</ItemGroup>
</Project>