Forum Xamarin.Android

An Exception was thrown by the type initializer

I'm getting this exception when i run my application in release mode. Works fine in debug. I thought initially it had to do with the linker, but i have removed that and now include everything and still receiving the error. the app is using TinyIOC,

I Inherited this app and this is the first time I've actually had to do anything with it, the top error occurs even if i run in debug mode, not sure if that could be the root of the issue but i don't think so.

Please see attached image for error received.


  • MihaMarkicMihaMarkic SI ✭✭✭✭

    Do you have any #if directives in code?

  • InitLiptonInitLipton USMember

    Hi @MihaMarkic thanks for your response, well the app is using TinyIOC and SQLLite which both use directives, and it seems to be causing the issue when trying to resolve the object using TinyIOC when in Release mode.

    E/AndroidRuntime(19928): at TinyIoC.TinyIoCContainer.ResolveInternal (TinyIoC.TinyIoCContainer/TypeRegistration,TinyIoC.NamedParameterOverloads,TinyIoC.ResolveOptions)

    but there's no more directives.

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    You sure you are not linking anything?

  • InitLiptonInitLipton USMember

    I've set the app to not link to try resolve the issue. the app should be around 17mb and now its 43. Cheers for your help. I've tried this step a few times on both Visual studio and Xamarin Studio, both with same result.

    Cheers for helping, given me more things to look into

  • MihaMarkicMihaMarkic SI ✭✭✭✭

    You could create a simple sample that reproduces the problem and post it here.

  • InitLiptonInitLipton USMember
    edited June 2015

    @MihaMarkic i've been able to replicate it in a sample app. Will work in debug mode but throws the same exception above. I've used TinyIoc in the sample app also but i've tested without and same issue occurs.

    I'm going to try update the NetTopologySuite that it references.

    I have also built this app as a console application and it works in release.

  • InitLiptonInitLipton USMember

    I've no idea what the issue is or what's causing the issue. The only resolution was to revert back to Xamarin 3.9.547. Since Xamarin 3.11.445 the issue arises.

Sign In or Register to comment.