Bug 32487

Summary: CS0016 Could not write to file Argument is out of range
Product: [Mono] Compilers Reporter: John Miller [MSFT] <john.miller>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+monotouch, mono-bugs+mono, rolf
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description John Miller [MSFT] 2015-07-27 14:08:31 UTC
**Overview:**

   While trying to compile a binding project, a compile error happens. 

   CSC: error CS0016: Could not write to file #######, cause: Argument is out of range.

**Steps to Reproduce:**

   1. Open the (private) sample app provided in the private comments below in Xamarin Studio on a Mac.
   2. Rebuild the project. 

**Actual Results:**
   
   An error occurs during building.
   See attached build log. 

**Expected Results:**

   No errors. 

**Build Date & Platform:**

=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: e01c3049-a2d2-4e0a-aad8-afe6fb627c4d
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.11.0.1232 (Business Edition)
Hash: 26c6349
Branch: master
Build date: 2015-07-16 11:18:45-0400

=== Xamarin.Android ===

Version: 5.1.4.16 (Business Edition)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.2.35 (Business Edition)

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.10.2
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-07-28 06:57:06 UTC
That's an _extra_ large binary... and that's also the problem. The native library will be embedded inside the binding assembly, and it's likely 3GB is hitting a file format limitation somewhere.

@Marek, can you have a look and see if this is the case? If it is, it would be nice to have a better error message (resource file too big), than the current error.

For a workaround my suggestion would be to remove the native library from the binding project, and instead link with it manually (passing -gcc_flags ... to mtouch [1]).

[1] http://developer.xamarin.com/guides/ios/advanced_topics/native_interop/
Comment 4 Marek Safar 2015-07-31 08:38:28 UTC
Fixed the error message. The file limit is still in place as PE/COFF supports 32-bit image size only
Comment 5 Marek Safar 2015-08-28 03:35:16 UTC
Mono master has now support for up to 4GB output files 

commit 252908a7d5471e3c50b35bb77cb26aaebab0656a