The Module "aspnetcorev2.dll" failed to load

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://docs.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://docs.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://docs.microsoft.com/en-us/dotnet/core/tools/global-json


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.


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.