Question IIS Error HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure


New member
Jul 18, 2022
Programming Experience
Hello, everyone,
I've been trying to get my project running on an IIS server under Windows Server 2019 for days now.

I set .net Core 3.1 as the target framework in Visual Studio

Since I'm using a 32-bit DLL, I set 32-bit to true in the IIS Application Pool

It runs under Visual Studio with IIS Express, but if I publish it now and want to start it on the server, I get the following message in the browser:
HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

In the log file I see the following message:
Unhandled exception. System.BadImageFormatException: Could not load file or assembly 'C:\inetpub\Test_Services\test.dll'. An attempt was made to load a program with an incorrect format. File name: 'C:\inetpub\Test_Services\test.dll'

My csproject file looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">


  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">

    <PackageReference Include="Microsoft.AspNetCore.Cors" />
    <!-- <PackageReference Include="Microsoft.AspNetCore.All" Version="3.1.27" /> -->
    <PackageReference Include="System.Private.ServiceModel" Version="4.9.0" />
    <PackageReference Include="System.ServiceModel.Duplex" Version="4.9.0" />
    <PackageReference Include="System.ServiceModel.Http" Version="4.9.0" />
    <PackageReference Include="System.ServiceModel.NetTcp" Version="4.9.0" />
    <PackageReference Include="System.ServiceModel.Security" Version="4.9.0" />

    <WCFMetadata Include="Connected Services" />

  <ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>


The Web.config:
<?xml version="1.0" encoding="utf-8"?>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    <aspNetCore processPath="dotnet" arguments=".\test.dll" stdoutLogEnabled="true"
        stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
        <aspNetCore processPath="dotnet" arguments=".\test.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
                <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/>
                <handlerSetting name="stackSize" value="2097152"/>
    <!-- <location path="." inheritInChildApplications="false">
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      <aspNetCore processPath="dotnet" arguments=".\test.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </location> -->
                <binding openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00"/>
        <!-- erstmal herausnhemen zum test<defaultProxy>
      <proxy autoDetect="false" bypassonlocal="false" proxyaddress="" usesystemdefault="false" />
    </defaultProxy> -->

Attached are a few pictures of the settings and installations


  • Installation.png
    87.4 KB · Views: 50
  • IIS_configuration.png
    80.5 KB · Views: 50
  • publish.png
    11.2 KB · Views: 49
  • projectsettings.png
    4.5 KB · Views: 49
Your .NET CLR version setting in IIS should be "No managed code".

Once you change that and it still doesn't work, check the "logs\stdout" for any logs that give you more of a hint as to what is failing.

As an aside, .NET Core 3.1 hits end of life this Dec 13, 2022. You'll need to plan ahead on porting to .NET 6.
Oh, another thing. On the IIS server, check to see whether the 32-bit or the 64-bit version of .NET Core was installed. If the server owner installed the ".NET Core Hosting bundle", both should be present.
I have changed it to ""No managed code" but i get the same error

Attached are picture with the installed .net Version in 32 and 64 bit

Does anythimng missing?


  • Installation2.png
    169.8 KB · Views: 107
Try changing the processPath="dotnet" to processPath="C:\Program Files (x86)\dotnet\dotnet".

If that fails, and you have a corresponding "test.exe" for your "test.dll" as part of your publishing output, try removing arguments and changing processPath to processPath="C:\inetpub\Test_Services\test.exe" .

If that still fails revert back to the original values for processPath and argumets, and run the SysInternals Process Monitor to see which version of dotnet.exe it is trying to use. Is it the dotnet.exe in the "Program Files (x86)" folder, or is it the one in the "Program Files" folder?

Latest posts

Top Bottom