MissingMethodException Additional Information: Method not found: '!!0[] System.Array.Empty()'. - by Matthew Adams

Status : 

 


25
0
Sign in
to vote
ID 1097462 Comments
Status Active Workarounds
Type Bug Repros 4
Opened 1/22/2015 9:24:47 AM
Access Restriction Public

Description

After updating my projects to use .NET Framework 4.6 from .NET Framework 4.5.3, I am getting a missing method exception when calling an otherwise ordinary looking method.

I have a couple of serialization interfaces:

    public interface ISerializer
    {
        Formatting Formatting { get; set; }

        object Deserialize(string input);

        object Deserialize(Stream input);

        string Serialize(object item);

        void Serialize(object item, Stream output);
    }

    public interface ISerializer<T> : ISerializer
    {
        new T Deserialize(string input);

        new T Deserialize(Stream input);

        string Serialize(T item);

        void Serialize(T item, Stream output);
    }

A fairly standard implementation of this includes the following methods
CompoundEntitySerializer : ISerializer<CompoundEntity>
{
        // Snip... 
        public string Serialize(CompoundEntity entity)
        {
             // Snip...
        }

        public string Serialize(object item)
        {
            return this.Serialize((CompoundEntity)item);
        }
}

Any call to the strongly typed version of Serialize() blows up with the missing method exception (including via the non-strongly typed method).

This is preventing us from continuing development using this CTP, and we may have to repave and roll back to the previous Preview build.
Sign in to post a comment.
Posted by Linda Li on 2/16/2017 at 5:42 AM
We got this issue after we switch to use VS 2015 build engine. It is a random error with .NET 4.6.0. Same code using VS 2013 to build works, but not with VS 2015. If upgrading to .NET 4.6.1 on the target machine, the issue is gone.

The thing is for some customer we cannot upgrade ,NET version to 4.6.1 because 4.6.1 does not support SBS 2011 which includes Exchange 2010 SP3 according https://technet.microsoft.com/en-us/library/ff728623(v=exchg.150).aspx

We have huge code base and not sure which line of code introduces the issue.
We'd really like a fix from Visual Studio 2015. build engine.

Thank you!
Ping
Posted by Michael Freidgeim on 6/26/2016 at 8:24 PM
@Alexandru, You shouldn't consider such confusing error message "by-design". The message should give instructions: "The code was compiled against .NET 4.6, install it on your machine"
Posted by TechArtists on 6/21/2016 at 11:00 AM
I received this error in two cases with the following environment:
Targeting 4.5.2
Build machine: 4.6
Deployment machine 4.5.2

1) I get this error using string interpolation: string.format($"Hello {UserName}");
2) After creating a SqlCommand passing in a stored procedure name to the constructor, I redundantly set the CommandText value. Removing the redundant property setting avoids the issue.
Posted by Microsoft on 9/22/2015 at 9:35 PM
Hi

Most likely what is happening is that:
- The code is compiling against .NET 4.6, where the reference assemblies include Array.Empty<T>().
- The Roslyn compiler sees that Array.Empty<T> is available and so uses it when generating the empty array needed for the params.
- The compiled app is trying to run on .NET 4.5 where Array.Empty doesn’t exit.

If the above is not the case, please let us know. Otherwise, this is by-design.

Thank you,
Alex
.NET Framework
Posted by JL-IDLA on 8/4/2015 at 7:50 AM
I get this error with an ASP.NET C# web app that was previously targeting 4.5.2 and now is set to 4.6.
This is running on a local server not Azure. I have already installed the released 4.6 targeting pack.
The server is Windows Server 2008 R2 and I tried a reboot after installing the targeting pack to ensure that wasn't an issue.

What else is needed to resolve this (besides not using .NET 4.6).
Posted by bradygaster on 5/31/2015 at 9:54 AM
I'm writing to you from the Visual Studio Web Tools Extensions team. My team is responsible for the Web publishing and App Service-related Visual Studio tools. We recently had discussions with the App Service (previously known as Azure Web Sites) team about .NET framework updates coming at the same time as Visual Studio 2015.

At this time, the support for 4.6 isn't yet deployed to App Service. App Service will support .NET 4.6 within 2-3 months after the official release of .NET Framework 4.6. In the meantime, the recommendation is to use .NET 4.5.2 for applications you intend on publishing to App Service.

Many announcements will come at the time that 4.6 is supported on App Service, but I'll monitor this thread and once the update is on 4.6 I'll update this post with more information.
Posted by Jorge.Alvarado.Frontiers on 5/10/2015 at 6:33 AM
I have the same problem, any suggestions?
Posted by David_Hettinger on 5/4/2015 at 10:04 AM
I don't get this on my local PC but I get it after deploying a blank app to azure:


Server Error in '/' Application.

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()'.]
KamelotAPI.BundleConfig.RegisterBundles(BundleCollection bundles) +0
KamelotAPI.WebApiApplication.Application_Start() +141

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

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




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36215
Posted by grldsndrs on 5/4/2015 at 12:27 AM
I got the same-exact error while going through the Getting Started with EF and MVC 5 on the ASP.NET website (http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application).

I am using .NET framework 4.6 as well but the Visual Studio 2015 RC.

I notice that this issue has been open for quite a while. Is there really no resolution yet?
Posted by Liam Finnie on 2/14/2015 at 7:47 AM
I am also experiencing the same issue.

I am converting a WebApi2 application from 4.5.1 to 4.6. All local compilation and testing through IIS Express works as expected. When using the 'Publish Web" option in VS 2015 CTP to push to Azure I get the 'Method not found: '!!0[] System.Array.Empty()' error message. I notice that in the Azure portal under the Configuration settings that the '.NET FRAMEWORK VERSION' section only has options for 3.5 and 4.5. Do we have to wait until 4.6 is an option for this issue to be resolved?
Posted by Scott T Allen on 2/11/2015 at 6:17 AM
Experiencing the same error, Started new project, selected framework 4.6 and new web application. Selected MVC and host in the cloud. Signed into Azure and configured Azure website settings (left defaults). Selected database, put in password. VS2015 started creating the application. Built and ran locally, everything fine. Published to Azure (web deploy). So no changes made to application (stock standard). On completion of publish website loads with error:

Server Error in '/' Application.

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()'.]
Test.BundleConfig.RegisterBundles(BundleCollection bundles) +0
Test.MvcApplication.Application_Start() +98

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

[HttpException (0x80004005): Method not found: '!!0[] System.Array.Empty()'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Posted by Microsoft on 1/26/2015 at 12:14 AM
Hello again. We wanted to give you a quick reminder that to efficiently investigate and reproduce your issue, we need you to submit the additional information we requested. If we haven't heard back from you with the requested information in the next 3 days, we will go ahead and close the issue.
Posted by Fabian Koenig on 1/25/2015 at 12:00 PM
I noticed the same issue and opened a bug report too.

For some reasons the System.Array.Empty<T>() function can't be found. It's a new one in the mscorlib.dll
Posted by Microsoft on 1/22/2015 at 6:20 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/ph/1117.
Posted by Microsoft on 1/22/2015 at 9:31 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If you require immediate assistance with this issue, please contact product support at http://support.microsoft.com/ph/1117.