[mono-android] Could not load type exception (generic interfaces in a class library) Preview 14

Jonathan Pryor jpryor at novell.com
Tue Mar 15 08:52:47 EDT 2011


On Mar 15, 2011, at 7:31 AM, Amir Waldman wrote:
> I tried using the 'Preserve' attribute trick on a few classes, but instead of giving me the name of the type in the exception as it did before, it simply showed a very general exception (with no type specified): 'A type load exception has occurred.'

More context would be useful, specifically the `adb logcat` lines surrounding that exception message. A sample to reproduce would be good, too. I assure that I also tested this with a sample project (one library + one app project, as you originally specified) and adding [Preserve(AllMembers=true)] made it work for me, so I find it odd that it's not working for you.

> I should add that the class that I reported earlier is derived from another class that is derived from another class that implements an interface (that was the 'A' class if you check my code sample. A : A1 => A1: A2 => A2 : IA). Even when I added the 'Preserve' attribute to the entire hierarchy, I still got the general 'type load' exception with no type specified. It is specified only when there was no use of this attribute at all. Furthermore, I couldn't see any indication for this in the ADB log like Jon showed in a  previous message.

Again, a full sample would be helpful in reproducing the issue.

> I just changed Linking in both class library and main assembly to 'Sdk Assemblies Only' and it loads again (that's all I checked for now). I don't see any changes in the size of the APK either since Preview 13.

You shouldn't see a significant change, as (presumably) your assemblies are (currently) tiny in comparison to the entire framework.

> Thanks for looking into this, I'd like to use the full capabilities of the linker. What are the benefits of linking user assemblies?

Mostly to shrink the resulting package as much as possible, which can be increasingly useful as you include larger frameworks with your app while not using the full capabilities of those frameworks. (For example, Cadenza.dll is 224KB in size, and if you only use small portion of it there's no need to waste space on the rest of it...)

 - Jon



More information about the Monodroid mailing list