Click here to Skip to main content
15,868,016 members
Articles / .NET
Technical Blog

MonoTouch – MonoDevelop Linker Hell

Rate me:
Please Sign up or sign in to vote.
4.67/5 (3 votes)
27 Feb 2013CPOL1 min read 9.7K   4   2
One of the first learning experiences I had when I dove into development was the linking functionality built into MonoTouch.

OverDog is my first project which uses Xamarin, a cross-platform tool for creating applications in C#. I've nothing but adoration for the platform, but one of the first learning experiences I had when I dove into development was the linking functionality built into MonoTouch.

The linker basically reads your applications possible execution paths and removes unused code. I was unaware of this functionality when I started development, but soon ran into problems when trying to deserialize some JSON into a class I created to hold user data. The JSON.NET library was telling me that my class was missing a default constructor, which simply wasn't the case. What I came to realize was that the linker was pulling out most of my data structures!

I alleviated the problem by attaching a [Preserve] compiler tag to each of my data model classes. To prevent all members of the class from being touched by the linker, you simply add an AllMembers argument:

C#
[Preserve(AllMembers=true)]
public class User
{
...
}

That solved my issues with the linker. This was a huge headache without any obvious acknowledgment by MonoTouch that this was occurring. What was confusing to me is the fact that my application's execution paths should have included my model data classes. The fact that they were being chopped up by the linker seems to be a bug.

This article was originally posted at http://kieferhagin.me?p=48

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer OverDog
United States United States
Software Developer at OverDog

Comments and Discussions

 
GeneralMy vote of 5 Pin
YannicSt28-Feb-13 7:46
YannicSt28-Feb-13 7:46 
GeneralRe: My vote of 5 Pin
Kiefer Hagin28-Feb-13 7:48
Kiefer Hagin28-Feb-13 7:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.