Method not found: '!!0[] System.Array.Empty()'

103

I created a new app with VS 2015 RC and the MVC template and without modifying any line of code I have this error:

Method not found: '!!0[] System.Array.Empty()'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[MissingMethodException: Method not found: '!!0[] System.Array.Empty()'.]
   SAASApp.BundleConfig.RegisterBundles(BundleCollection bundles) in C:\Proyectos\SAASApp\SAASApp\App_Start\BundleConfig.cs:29
   SAASApp.MvcApplication.Application_Start() in C:\Proyectos\SAASApp\SAASApp\Global.asax.cs:18

[HttpException (0x80004005): Method not found: '!!0[] System.Array.Empty()'.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +483
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +350
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +305

[HttpException (0x80004005): Method not found: '!!0[] System.Array.Empty()'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +661
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +96
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +189

First time it happens to me, so I am stuck at the moment

c#
asp.net
asp.net-mvc
asp.net-mvc-3
asked on Stack Overflow Jul 6, 2015 by Luis Valencia • edited Aug 28, 2018 by StayOnTarget

9 Answers

200

I had this situation on the production server while on development machine everything was OK.

Installing .NET Framework 4.6 on the target machine has fixed the problem.

answered on Stack Overflow Aug 18, 2015 by Andrey Kovalenko
23

Sorry for being late to the party, but in case someone else gets this problem via a TeamCity build, I can describe what we had to do.

.NET 4.6 was installed on our build server (but not on the application server), and the RunnerType was Visual Studio (sln) and the Visual Studio option was set to 2015.

This forced the build to use 4.6, and I needed to change the Visual Studio option to 2013 to force the build to use 4.5.2

answered on Stack Overflow Feb 12, 2016 by gautejohan
9

Just For others facing this situation:

if you look in the web.config file you will realize that in <compilation> tag you have the value targetFramework set to a version below 4.6. but in fact , at build time you published your application via .NET FrameWork 4.6 or above (Corresponds to ASP.NET MVC 4.6 and above).

So if you change the value of targetFramework to 4.6 the error will change shape into :

The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework.

this is the real error and you will get rid of it by installing appropriate Version of .Net FrameWork in production environment of your Web App.

answered on Stack Overflow Aug 30, 2016 by AmiNadimi
2

Updating the .NET Framework to its latest (4.7.2) resolved the issue. Thanks to @Andrey Kovalenko for solution.

But should not the error be like,

enter image description here

I am not sure telling each customer about updating their .NET Framework is applicable. I had this issue especially at Windows Embedded OS installed system, only at production environment.

Is there any other way to overcome the behavior, from our code base itself.?

answered on Stack Overflow Dec 25, 2018 by Naveen Kumar V • edited Dec 27, 2018 by Naveen Kumar V
1

I try these solution without success.

The solution for me was go to the application pool, turn to 2.0, execute the site on browser, see the error (because the version is wrong) and turn back to 4.0 and "voilà", I got it, the website open.

answered on Stack Overflow May 17, 2017 by Roberto Gentile
0

In my case, I had a corrupt .NET installation on my Windows Server 2012 R2. I had to install a more recent version of .NET (v4.7.1) and the site is working now.

answered on Stack Overflow Oct 28, 2017 by André Hauptfleisch
0

In my case, I don't have access to the IIS itself and I was having this problem when I was using a single method which doesn't have anything special only things from .net 2.

The solution: I've Extracted that method and created a Class Library with .net 2.0 and it works.

answered on Stack Overflow Jan 10, 2018 by Ricardo França
0

Maybe it too late but I got the same problem and fixed as below. I use Visual Studio 2015 ,the configuration compilation on web.config point to .NET FrameWork 4.6 by default. I could not just edit only on the web.config file. If you can not install .NET FrameWork 4.6 on server and your application don't use it.

  1. Go to menu Debug > [Project Name] Properties > Application .
  2. choose the .NET Framework 4.5 (or any which server support and compatible your application) from Target Framwork dropdown list.
  3. Rebuild again.
answered on Stack Overflow Jun 21, 2018 by waewta artpongsa • edited Jun 21, 2018 by waewta artpongsa
0

I have downgraded 4.6.x to 4.5.2 and it worked fine.

answered on Stack Overflow Oct 2, 2018 by Bhavesh Patel • edited Oct 2, 2018 by scopchanov

User contributions licensed under CC BY-SA 3.0