Bug 30564 - Exception caused by "Include mono runtime in the app bundle"
Summary: Exception caused by "Include mono runtime in the app bundle"
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Other ()
Version: 1.12.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
Depends on:
Reported: 2015-05-28 22:46 UTC by xambugz
Modified: 2015-06-04 10:51 UTC (History)
1 user (show)

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

Attempted Repro (21.65 KB, application/zip)
2015-06-02 16:35 UTC, Chris Hamons

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 Developer Community or GitHub 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:

Description xambugz 2015-05-28 22:46:42 UTC
Our production release ran into this bug. I tracked it down, and it is reproducible with the following steps. The following code should not throw any exceptions - 

If you enable "Include mono runtime in the app bundle" the following code throws exception. If you don't include mono runtime, the code behaves correctly; no exceptions.

This is a bug with Xamarin.Mac, somehow causing a problem when including mono runtime in app bundle.

Create a new Xam.Mac Cocoa App, Classic API.

Right-click the project, Options, Mac Build, Yes include mono runtime. Keep the defaults: Sdk version default (I also tried 10.9 and 10.10). Linker behavior: Don't link. Don't use SGen. Don't use reference counting.

Add reference to Mono.Security and add these:
using Mono.Security.X509;
using System.Diagnostics;

Paste this into DidFinishLaunching, and Start Debugging. It should not throw exception, and it behaves correctly *only* if you un-check mono runtime bundling.

// This is the first cert fetched from server, by MozRoots
const string rawdataString = @"MIICNDCCAaECEAKtZn5ORf5eV288mBle3cAwDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVM" +
    @"BAQUAA4GJADCBhQJ+AJLOesGugz5aqomDV6wlAXYMra6OLDfO6zV4ZFQD5YRAUcm/jwjiioII0haGN1XpsSECrXZogZoFokvJSyV" +
    @"mIlZsiAeP94FZbYQHZXATcXY+m3dM41CJVphIuR2nKRoTLkoRWZweFdVJVCxzOmmCsZc5nG1wZ0jl3S3WyB57AgMBAAEwDQYJKoZ" +
    @"IhvcNAQECBQADfgBl3X7hsuyw4jrg7HFGmhkRuNPHoLQDQCYCPgmc4RKz0Vr2N6W3YQO2WxZpO8ZECAyIUwxrl0nHPjXcbLm7qt9" +
byte[] rawdata = Convert.FromBase64String (rawdataString);

X509Certificate cert = new X509Certificate (rawdata);

// Hash and IsSelfSigned both throw NullReferenceException
bool foo;
try {
    foo = cert.IsSelfSigned;
    Debugger.Break (); // Got here with no Exception
catch (Exception e) {
    Debugger.Break ();
Comment 1 Chris Hamons 2015-06-02 16:35:52 UTC
Created attachment 11440 [details]
Attempted Repro
Comment 2 Chris Hamons 2015-06-02 16:37:02 UTC

I'm having trouble reproducing this issue. I've attached the project I tried to use to reproduce it.

Could you post you Xamarin Studio -> About -> Show Details and take a look at my reproduction case to see what I'm missing.
Comment 3 xambugz 2015-06-03 10:13:00 UTC
I downloaded your project. I made no modifications whatsoever. I ran it debugging (Run/Start Debugging) and got the exception. Here is my version information: 

=== Xamarin Studio ===

Version 5.9.1 (build 3)
Installation UUID: <snip>
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.3.2 (7718)
Build 6D2105

=== Xamarin.iOS ===

Not Installed

=== Xamarin.Android ===

Not Installed

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 509010003
Git revision: aad75a6e7e48f18120ce41f47d0ff2c6216f49c3
Build date: 2015-05-08 12:46:18-04
Xamarin addins: 1246b3044cbb7f56a217334f8fc5489ef8eefe3f

=== Operating System ===

Mac OS X 10.10.3
Darwin <snip> 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
Comment 4 Chris Hamons 2015-06-03 10:30:45 UTC
I see. You are running XM 1.12 and Mono 4.0. That is strange, that isn't the combination that we shipped (1.12 and 3.12) 

Updating to the latest stable fixes it for me. Is there any reason you can't move to that?
Comment 5 xambugz 2015-06-04 10:01:22 UTC
Ah - I didn't know. If updating fixes it, go ahead and close the bug. 

My subscription to Xam.Mac expired so I can't get the later version of Xam.Mac (for now). And it just so happens - The mono website no longer makes older versions of mono available for download.

Do you know somewhere I can get the mono 3.12 SDK? Can you tell me what version of Xamarin Studio and mono I should be on, if my latest Xam.Mac entitlement is 1.12?
Comment 6 xambugz 2015-06-04 10:10:00 UTC
In the wayback machine, I was able to browse Apr 26 to get a link to MDK 3.12. And in the Xamarin downloads page, I see Xamarin Studio 5.8.3 was current at the time. So I'll try again with XS 5.8.3, MDK 3.12, and Xam.Mac 1.12. And I'll just leave my tooling that way until we hopefully update our Xam.Mac subscription.

Thanks for your help.
Comment 7 Chris Hamons 2015-06-04 10:51:46 UTC
No problem. You could also ask on the forums here:


If you need a reference to an older package.