Bug 29577

Summary: After update to version 5.9 build 431 Can not build iOS project.
Product: iOS Reporter: Guram <buulioni>
Component: GeneralAssignee: Rolf Bjarne Kvinge [MSFT] <rolf>
Status: RESOLVED DUPLICATE    
Severity: normal CC: mono-bugs+monodevelop, mono-bugs+monotouch, pj.beaman, rolf, saurabhd, tg
Priority: Normal    
Version: XI 8.10   
Target Milestone: 8.10.1 (C5SR1)   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Guram 2015-04-30 05:13:51 UTC
Error is following:

Error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com (MT0000)

Here is output:

Mono.Cecil.ResolutionException: Failed to resolve System.Security.Permissions.SecurityPermissionFlag
  at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum (Mono.Cecil.TypeReference enum_type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArgument (Mono.Collections.Generic.Collection`1& fields, Mono.Collections.Generic.Collection`1& properties) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArguments (UInt16 count, Mono.Collections.Generic.Collection`1& fields, Mono.Collections.Generic.Collection`1& properties) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadSecurityAttribute () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.MetadataReader.ReadSecurityDeclarationSignature (Mono.Cecil.SecurityDeclaration declaration) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SecurityDeclaration.<Resolve>m__1 (Mono.Cecil.SecurityDeclaration declaration, Mono.Cecil.MetadataReader reader) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Read[SecurityDeclaration,SecurityDeclaration] (Mono.Cecil.SecurityDeclaration item, System.Func`3 read) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SecurityDeclaration.Resolve () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SecurityDeclaration.get_SecurityAttributes () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadSecurityDeclarations (ISecurityDeclarationProvider provider) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadMethods (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadTypes (Mono.Collections.Generic.Collection`1 types) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadModule (Mono.Cecil.ModuleDefinition module) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at MTouch.SaveAssembly (Mono.Cecil.AssemblyDefinition assembly, System.String destination) [0x00000] in <filename unknown>:0 
  at MonoTouch.Assembly.RemoveResources (Boolean remove_resources, System.String target_directory, System.String nores_directory) [0x00000] in <filename unknown>:0 
  at MonoTouch.Target.ProcessAssemblies () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.BuildApp () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.Build () [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Saurabh 2015-04-30 06:11:45 UTC
I have tried to reproduce this Issue after upgrading to stable builds. But I am not getting this Issue for iOS application. I am successfully able to build iOS application in both Debug and Release mode.

@Guram, Could you please paste the version info from XamarinStudio->About XamarinStudio and copy information? 

Also please let me know are you getting this Issue after creating iOS template?

This is version info at my end:
=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: 2939b8b4-8977-42bd-82d6-100275ccd9cd
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.0.267 (Enterprise Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

=== Xamarin.Android ===

Version: 5.1.0.115 (Enterprise Edition)
Android SDK: /Users/360_macmini/Library/Developer/Xamarin/android-sdk-mac_x86
	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.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

=== Xamarin Android Player ===

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

=== Xamarin.Mac ===

Version: 2.0.0.262 (Enterprise Edition)

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Mac OS X 10.9.4
Darwin 360-MACMINIs-Mac-mini-2.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 2 Guram 2015-04-30 06:16:39 UTC
Here is version info.

Xamarin Studio
Version 5.9 (build 431)
Installation UUID: b0ed0bae-7533-40dc-9efc-7a5c4fa8435b
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

Apple Developer Tools
Xcode 6.3.1 (7703)
Build 6D1002

Xamarin.iOS
Version: 8.10.0.267 (Business Edition)
Hash: 6481535
Branch: master
Build date: 2015-04-27 04:38:13-0400

Xamarin.Android
Version: 5.1.0.115 (Business Edition)
Android SDK: /Users/buulioni/Documents/adt-bundle/sdk
	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.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

Xamarin Android Player
Not Installed

Xamarin.Mac
Version: 2.0.0.262 (Starter Edition)

Build Information
Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

Operating System
Mac OS X 10.10.3
Darwin Gurams-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64



----

Also please notice that when I changed Link behavior from "Link SDK Assemblies only" to "Don't Link" build was successful
Comment 3 Thomas G 2015-04-30 07:46:29 UTC
I have this exact same problem, I should have not accept this update...
Comment 4 PJ 2015-04-30 12:09:32 UTC
Hi Thomas, Guram,

Sorry to hear about your experience. Can you add your full diagnostic build output [1] and, if possible, the full app that demonstrates the issue?

[1] https://forums.xamarin.com/discussion/27515/how-to-obtain-diagnostic-build-logs
Comment 5 Thomas G 2015-04-30 12:18:51 UTC
Sorry i'm not allowed to send the affected application
Here is the stacktrace in the build output:

Xamarin.iOS 8.10.0 Business Edition using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk
error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
Mono.Cecil.ResolutionException: Failed to resolve System.Security.Permissions.FileIOPermissionAccess
  at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum (Mono.Cecil.TypeReference enum_type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArgument (Mono.Collections.Generic.Collection`1& fields, Mono.Collections.Generic.Collection`1& properties) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadCustomAttributeNamedArguments (UInt16 count, Mono.Collections.Generic.Collection`1& fields, Mono.Collections.Generic.Collection`1& properties) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SignatureReader.ReadSecurityAttribute () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.MetadataReader.ReadSecurityDeclarationSignature (Mono.Cecil.SecurityDeclaration declaration) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SecurityDeclaration.<Resolve>m__1 (Mono.Cecil.SecurityDeclaration declaration, Mono.Cecil.MetadataReader reader) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Read[SecurityDeclaration,SecurityDeclaration] (Mono.Cecil.SecurityDeclaration item, System.Func`3 read) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SecurityDeclaration.Resolve () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.SecurityDeclaration.get_SecurityAttributes () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadSecurityDeclarations (ISecurityDeclarationProvider provider) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadMethods (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadType (Mono.Cecil.TypeDefinition type) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadTypes (Mono.Collections.Generic.Collection`1 types) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ImmediateModuleReader.ReadModule (Mono.Cecil.ModuleDefinition module) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00000] in <filename unknown>:0 
  at MTouch.SaveAssembly (Mono.Cecil.AssemblyDefinition assembly, System.String destination) [0x00000] in <filename unknown>:0 
  at MonoTouch.Assembly.RemoveResources (Boolean remove_resources, System.String target_directory, System.String nores_directory) [0x00000] in <filename unknown>:0 
  at MonoTouch.Target.ProcessAssemblies () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.BuildApp () [0x00000] in <filename unknown>:0 
  at MonoTouch.Application.Build () [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 6 Thomas G 2015-04-30 12:20:50 UTC
Additional informations:
- On the prior version everything worked fine
- If I switch to "Don't link" instead of "Link SDK assemblies only", it works, but my app crash during startup
- It fails only when building for device, when building for simulator, it works
Comment 7 Rolf Bjarne Kvinge [MSFT] 2015-04-30 13:23:55 UTC
As a immediate workaround you can try removing the security declaration from your source (see original bug report) or try adding `--linkskip=mscorlib` to your "Additional mtouch arguments" in the iOS builds section of your project options.

*** This bug has been marked as a duplicate of bug 28918 ***