Bug 21578 - App crashes in Release builds. System.Net.Sockets.Socket.SetSocketOption getting stripped by linker?
Summary: App crashes in Release builds. System.Net.Sockets.Socket.SetSocketOption gett...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.12.4
Hardware: Macintosh Mac OS
: High normal
Target Milestone: 5.1
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2014-07-24 14:43 UTC by Jon Goldberger [MSFT]
Modified: 2015-04-20 10:38 UTC (History)
7 users (show)

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

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:
Status:
VERIFIED FIXED

Description Jon Goldberger [MSFT] 2014-07-24 14:43:20 UTC
From case:

I have an issue with the Socket class on Android when using release builds with SDK Linking enabled.

With linking disabled, the app runs correctly, when "Sdk Assemblies Only" is enabled, I get an unhandled exception.

This app is not doing anything when it comes to late-binding. I think some of the internals of the "System.Net.Sockets.Socket" class are getting stripped out incorrectly but I can't figure out what.

You can repro this by using the code here:
https://github.com/onovotny/Zeroconf

Set the ZeroconfTest.Xam.Android as the startup project and in Release mode, you'll see that with the Linker set to None, it works and with "Sdk Assemblies Only" it throws.
Comment 2 Jon Goldberger [MSFT] 2014-07-24 14:49:10 UTC
I was able to reproduce this issue. as described above. Crash occurs after pressing either of the buttons in the UI. 

Prashant (and I ) tried using a LinkDescription file to resolve the issue. See Gist: https://gist.github.com/prashantvc/28a6c3ca58db3dd058b9

Adding an XML file with the contents of that Gist and setting the Build Action to LinkDescription did not resolve the issue. Even trying to skip the entire assembly with:

><linker> 
>	<assembly fullname="System">
>	</assembly>
></linker>

did not resolve the issue. 

However entering

System;

in to the Ignore Assemblies field in the Project Options->Build->Android Build page does resolve the crash issue.
Comment 3 Radek Doulik 2014-10-31 07:48:58 UTC
This is now fixed in master by a055f1c498f7c4d5960cd1651c950604e9d9e6cc
Comment 4 Oren Novotny 2015-02-20 19:04:59 UTC
Hi, is this really fixed? Users are complaining this is not fixed yet.

https://github.com/onovotny/Zeroconf/issues/8
Comment 5 Radek Doulik 2015-02-23 10:42:10 UTC
It should be fixed, but it didn't get to any released version yet.
Comment 6 Udham Singh 2015-04-20 10:38:31 UTC
I have checked this issue with the help of sample app and instructions given in bug, and observed that this issue has been fixed. Screencast : http://www.screencast.com/t/SqkeXzNKv8

Hence I am closing this issue. Thanks!

Environment info : 

Mac OS X 10.9.5
Xamarin Studio 5.9 (build 431)
Mono 4.0.0 ((detached/c8db1b0)
GTK+ 2.24.23 (Raleigh theme)
Xcode 6.2 (6776)
Xamarin.Android 5.1.0.115 (Trial Edition)