Bug 36942 - .NET 4.6 running on mono, Method 'Array.Empty' not found. (Win and Linux)
Summary: .NET 4.6 running on mono, Method 'Array.Empty' not found. (Win and Linux)
Status: RESOLVED ANSWERED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: 4.2.0 (C6)
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-12-12 22:45 UTC by Dave
Modified: 2016-06-08 21:49 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
unit test / console line app which exhibits the issue (3.76 KB, text/plain)
2015-12-12 22:45 UTC, Dave
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Dave 2015-12-12 22:45:18 UTC
Created attachment 14262 [details]
unit test / console line app which exhibits the issue

[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'Array.Empty' not found.


This error seems to be appearing in a few Frameworks

https://bitbucket.org/dadhi/dryioc/issues/124/method-arrayempty-not-found-when-running
https://github.com/NancyFx/Nancy/issues/2064

The Nancy Guys think the following:

"This is what I think you're doing.

1.You are compiling your application on .NET Framework 4.6 where the absence of values to a params string[] parameter gets compiled into Array.Empty<T>() by Roslyn.
2.You then attempt to run this compiled application on an early build of .NET Framework or Mono, where Array.Empty<T> does not exist (source notice that it says Available since 4.6)"

Attached is an example bit of code which exhibits the issue.

it fails on the line

var subscribeAction = Expression.Lambda<Action>(callSubscribe); //Fails on mono
Comment 1 Marek Safar 2015-12-14 15:06:12 UTC
You need to upgrade to Mono 4.2 or newer which support .net 4.6
Comment 2 Craig Minihan 2016-06-07 09:57:00 UTC
I see this problem with Stable 4.2.3.4/832de4b.

It is easy to replicate:
* var array = new Array.Empty<string>();
* Build under VS2015 as a 4.6 app
* Run under Mono 4.2.3.4

You get:
craig@ubuntu:~/temp$ mono TestArrayEmpty.exe 

Unhandled Exception:
System.MissingMethodException: Method 'Array.Empty' not found.
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'Array.Empty' not found.

I originally saw this problem with RabbitMQ 3.6.2 from nuget with an app built by VS2015 and run up under Mono 4.2 as above. RabbitMQ does *not* use Array.Empty directly.
Comment 3 Federico Dipuma 2016-06-08 21:49:17 UTC
Same issue using Mono 4.2.3.4 stable under ARM Linux (Raspbian).

Encountered while testing a Nancy application as per this issue:

https://github.com/NancyFx/Nancy/issues/2064

The application was built using .net 4.6.2, when reverted to 4.5.2 the issue disappeared.