Fixing the ASP.NET MVC application runtime error “Method not found: !!0[] System.Array.Empty()”
Posted: (EET/GMT+2)
Today, I needed to investigate an interesting error on a production web site during deployment:
Method not found: '!!0[] System.Array.Empty()'.
This somewhat cryptic error was caused by a mismatch between the configured .NET runtime version on the web server and the application. The application was built for .NET 4.6.1, but the server was configured for .NET 4.5.2.
I must confess I haven't seen an exception with this particular method being referenced before, but even so, the error is easy to fix: correct the Web.config on the production server to match the correct .NET framework version, and optionally upgrade the .NET installation on the web server.
Happy hacking!