15

Recently I tried installing ASP.NET Core/.NET Core: Runtime & Hosting Bundle version 2.2 on a machine running Windows Server 2008 R2 SP1. However, after installing IIS stops working and gives 503 Service unavailable error for all applications hosted in it. After checking the application pools I see that the pools just shuts down.

In the event viewer I can see the following error message -

The Module DLL C:\Program Files (x86)\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll failed to load. The data is the error.

I have tried setting the pool to both 32/64 bits, but the error is the same. Did anybody else face this problem or have solution for this?

th1rdey3
  • 4,176
  • 7
  • 30
  • 66
  • 1
    Check carefully the event log entry, as it also contains an error code, which you can use to learn more about the crash. – Lex Li Jan 14 '19 at 23:37
  • Does this answer your question? [Failed to load aspnetcorev2.dll hosting ASP.NET Core 2.2 on IIS7](https://stackoverflow.com/questions/54368738/failed-to-load-aspnetcorev2-dll-hosting-asp-net-core-2-2-on-iis7) – Will Wu Apr 03 '20 at 01:47

5 Answers5

24

After reading through the following documents -

Troubleshoot ASP.NET Core on IIS

and

Common errors reference for Azure App Service and IIS with ASP.NET Core

I came to know that the ASP.NET Core/.NET Core: Runtime & Hosting Bundle (latest versions) depends on Microsoft Visual C++ 2015 Redistributable. The machine in question had earlier versions of vc++ redist installed. After installing the said version of redistributables (both 32 & 64 bit) everything started working again.

Funny thing is the ASP.NET Core/.NET Core: Runtime & Hosting Bundle Version 2.2 installer didn't throw any errors or warnings during installation about the missing vc++ 2015 redist.

th1rdey3
  • 4,176
  • 7
  • 30
  • 66
  • 1
    Installing Microsoft Visual C++ 2015 Redistributable (both 32 & 64 bits) didn't work for me. I have the same issue you stated in your original question. I tried with dotnet-hosting-2.2.1, 2.2.2 and 2.2.4 versions, and I had the issue of IIS going down with same error message in the event viewer with any of them. – zed Apr 11 '19 at 03:22
  • I also tried installing Microsoft Visual C++ Redistributable 2017 (both 32 & 64 bits). Same thing (IIS failing for all and any request) – zed Apr 11 '19 at 03:36
  • well, i did face the same problem again later, but doing a simple repair on the setup file solved the issue. – th1rdey3 Apr 11 '19 at 07:15
  • 2
    It fixed my problem right away . Even my normal Non Core websites were giving errors – Iman Aug 25 '19 at 12:24
  • 1
    Ran into this on a fresh install of Windows Server 2012 R2 w/ current updates and .NET 4.7.2 installed. The Visual C++ 2015 Redistributable x64 install fixed it right up. (It would have been nice if the vendor of the application had included this in their pre-reqs... >sigh<) – Evan Anderson Sep 24 '19 at 18:17
  • 1
    My issue was that something I installed had installed the x86 version so I had both installed. After uninstalling the x86 version and restarting, all was back to normal. – Carl Reid Apr 14 '20 at 15:41
  • The vc++ redistributable I needed for Windows 2012 R2 was mentioned here: https://learn.microsoft.com/en-us/dotnet/core/install/dependencies?pivots=os-windows&tabs=netcore31 – Mike May 28 '20 at 13:47
  • You saved my life, I have no other word for you – Hakan Fıstık Jul 23 '20 at 09:41
3

I noticed that C:\Program Files\IIS\Asp.Net Core Module indeed did not exist on my machine. I just copied over C:\Program Files\IIS Express\Asp.Net Core Module (elevated) which did exist and... the Application Pool started fine!

Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
1

That aspnetcorev2.dll is actually ASP.NET Core 2.0 Module, commonly called ANCM. This module needs some setup and configuration if the ASP.NET Core 2.0/2.1/2.2 is going to be run on top of IIS and use IIS as the main proxy before going to ASP.NET Core original Kestrel engine, and it's also called out-of-process model.

This is important, on other platforms other than Windows, all request goes directly to Kestrel and served by Kestrel directly. Therefore on IIS, a special configuration setup need to be done to use Kestrel on IIS.

For more information about ANCM on IIS, please consult this official Microsoft Docs: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-2.2

NOTE: although that page is for .NET Core 2.2, it's still applicable for .NET 2.0/2.1.

Based on your error, there's a chance that the ANCM DLL is not within the reach of the resulting DLL of your app. Ensure that the ANCM dll files are within your resulting compiled folder, not outside. Also ensure that you're using RTM or official release version of .NET Core 2.0/2.1/2.2 runtime instead of daily build, because using daily build of .NET Core 2.0/2.1/2.2 may bring some strange errors because their full distribution of runtime DLLs may not be fully coherent.

For more information about troubleshooting ANCM in ASP.NET Core 2.x, please consult this official MS Docs: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/troubleshoot?view=aspnetcore-2.2

UPDATE #1:

Based on comment below, I add this additional info: you should clear all nuget caches on your machine, restore and run MSBUILD again. If you use .NET Core 2.1 as the platform for your ASP.NET Core 2.1 app, then if you install .NET Core 2.2 without updating references of your app to v2.2, there's a chance that references still mixed up.

Or for better practice, use global.json file to strict your compilation of your app to always use .NET Core 2.1 SDK with specific version, regardless what is the latest version of .NET Core SDK you have on your machine. This is also important, because by default compiling .NET Core app will always try to use the latest SDK available on your machine, and previous existing older version will be ignored.

Setting up global.json is documented here: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

Eriawan Kusumawardhono
  • 4,796
  • 4
  • 46
  • 49
  • 1
    I had version 2.1 installed on this machine and it worked perfectly. But installing 2.2 gives error. As I see, the problem is within IIS because the error occurs before even the applications are loaded and all application (including older MVC and WebForms) are affected. After I uninstall version 2.2, IIS starts working again. – th1rdey3 Jan 14 '19 at 06:46
  • Then you should clear all nuget caches on your machine, restore and run MSBUILD again. If you use .NET Core 2.1 as the platform for your ASP.NET Core 2.1 app, then if you install .NET Core 2.2 _without_ updating references of your app to v2.2, there's a chance that references still mixed up. – Eriawan Kusumawardhono Jan 14 '19 at 06:50
  • My apps target `net471`. But as I said, installing version 2.2 makes IIS stop working all together. Even simple static file hosts stops working. – th1rdey3 Jan 14 '19 at 07:17
  • @th1rdey3 If your apps target net471, why do you use .NET Core 2.1? The ASP.NET Core 2.1 is not compatible with .NET4.7.1. Also your question doesn't mention any info about using .NET 4.7.1 and your tag is `net-core`. Your last comment is contradictory with your own question. – Eriawan Kusumawardhono Jan 14 '19 at 07:24
  • I am using .Net Core hosting bundle which is needed to host dotnetcoremvc app in IIS – th1rdey3 Jan 14 '19 at 09:39
  • @th1rdey3 dotnetcoremvc app requires ASP.NET Core 2.1, and ASP.NET Core 2.1 **requires** .NET Core 2.1, NOT .NET Framework. Where do you have doc that says dotnetcore mvc app is compatible with .NET Framework? Who said this??? Are you sure you have the correct target for the app? Otherwise I couldn't help you more. – Eriawan Kusumawardhono Jan 14 '19 at 10:58
  • When you create a new ASP.NET Core Web Application from visual studio there is an option to select target framework as .NET Framework. Also after creating a dotnet core app using dotnet-cli you can simply change the framework by editing the csproj file. – th1rdey3 Jan 14 '19 at 12:31
1

I had this same error on a new install of Windows 7 & I looked it up & found that it was indeed the missing update. To fix it you just need to download & install KB2999226 from https://www.microsoft.com/en-us/download/details.aspx?id=49077 (ie. this is for windows 7) & the problem was fixed directly. you didn’t need to go & download/install the whole Microsoft Visual C++ Redistributable package. No reboot either worked in a few minutes. you don’t need to have the 2015 nor 2017 packages installed, just 2013, 2010, 2008 & 2005 is enough.

Assefa Tedla
  • 93
  • 1
  • 4
0

See what worked for me in my answer on https://stackoverflow.com/a/73640078/993991. How I ended up uninstalling v2 of ASP.NET Core, but the same steps could be adapted to point to a newer version or at least the installed version.

Michael Russ
  • 81
  • 3
  • 10