Click here to Skip to main content
Click here to Skip to main content

Tagged as

MonoTouch – MonoDevelop Linker Hell

, 27 Feb 2013
Rate this:
Please Sign up or sign in to vote.
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:

[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.

License

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

Share

About the Author

Kiefer Hagin
Software Developer OverDog
United States United States
Software Developer at OverDog

Comments and Discussions

 
GeneralMy vote of 5 PinmemberYannicSt28-Feb-13 7:46 
GeneralRe: My vote of 5 PinmemberKiefer Hagin28-Feb-13 7:48 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 27 Feb 2013
Article Copyright 2013 by Kiefer Hagin
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid