HTTP Error 500.32 - ANCM Failed to Load dll

180 Views Asked by At

I have upgraded a .NET Core 2.1 web app to .NET 7.

The application works fine on Visual Studio 2022.

When I deploy that to Azure through Azure DevOps pipelines, I get the following error:

HTTP Error 500.32 - ANCM Failed to Load dll
Common solutions to this issue:
The application was likely published for a different bitness than w3wp.exe/iisexpress.exe is running as.
Troubleshooting steps:
Check the system event log for error messages Enable logging the application process' stdout messages Attach a debugger to the application process and inspect For more information visit: https://{this site name}.scm.azurewebsites.net/detectors and https://go.microsoft.com/fwlink/?LinkID=2028526

If I just add the following line to the project file, it works fine on Azure

     <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

I understood from experts that InProcess is better performing than OutofProcess and therefore would like to fix the issue with 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>

1

There are 1 best solutions below

0
Angelo On BEST ANSWER

I resolved the issue by following suggestions on

MVC Core - What is the difference between UseIIS and UseIISIntegration

changed

.UseIISIntegration()

to

.UseIIS()

Program.cs