How to fix error message 'Could not find 'aspnetcorev2_inprocess.dll' with IIS and .net8.0 self-contained ?

Lebret Pierre-Vincent 0 Reputation points
2023-11-15T18:03:05.5533333+00:00

I have a problem using a self-contained deployment with .net8.0 on IIS.

Everythink was OK using .net6.0 (even if i just have .net3.1 installed on the server).

I still build my project using --self-contained true

My package seems OK, the web config seems to be OK (it uses processPath=".\MyWebApi.exe" as before).

I have 403 items (133MB) in the wwwroot folder and a DDL named aspnetcorev2_inprocess.dll (v18.0).

But the app won't start.

I have this error on the browser : HTTP Error 500.31 - ANCM Failed to Find Native Dependencies

And I found this error in the event log : Could not find 'aspnetcorev2_inprocess.dll'. Exception message: You must install or update .NET to run this application.

But I don't want to install the framework ! that's why I use the self-contained flag !

Update day+1 :

  • I just reinstalled the last ".Net Hosting Bundle" but get the same problem.
  • I discovered that if i create the package from my VS myself (Right click, Publish, the package deployment works. There is something wrong with my package. I publish it as before with this existing command on my Pipeline :

dotnet publish MyWebApi.csproj --no-build --no-restore --configuration Release --runtime win-x64 --self-contained true /p:PublishProfile=Release

Update day+2 :

  • I fixed the error by removing the --no-build flag when publishing ! Why ? no documentation helps to understand this !?

Any help ?

Internet Information Services
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,604 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,582 Reputation points Microsoft Employee
    2023-11-16T07:06:37.44+00:00

    Unfortunately ever since .NET Core 1.0, hosting ASP.NET Core apps on IIS needs the Windows hosting bundle to be installed on IIS. "Self contained" might apply to console/desktop apps, but doesn't apply to web apps on IIS.

    0 comments No comments

  2. Yurong Dai-MSFT 2,821 Reputation points Microsoft Vendor
    2023-11-16T07:52:32.3066667+00:00

    Hi @Lebret Pierre-Vincent,
    Perhaps we all think that the benefit of doing a Self-Contained Deployment is not having to install anything, including the .net core framework. But if deployed to IIS, SCD is of little use. The hosting bundle is always a must, as ASP.NET Core module can only be installed from it. Please check out this thread.

    A self contained deployment does indeed include the runtime, but it doesn't include the ASP.NET Core module for IIS which you get when you download the Runtime & Hosting Bundle from the .net downloads page.

    You can build standalone .NET Core web applications. However, as Lex Li said, it is a console-based application that, when run, self-hosts with Kestrel or other HTTP server.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Yurong Dai

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.