Forum Xamarin.Android

CustomRenderers throw TargetInvocationException

leeyoleeyo USMember ✭✭
edited December 2017 in Xamarin.Android

Hi,

It's been a week that I'm developping a new app for Android & iOS. Almost each time I try to use a CustomRenderer on Android, app comes to crash with a "TargetInvocationException" (obviously no problem with Labels, but with ListViews it crashes). I can't say if it happens with iOS aswell because I actually don't have a Mac to build the code, but these issues are weird since it also procs with an empty renderer (!). I also tried to deploy a blank project, same result.

Visual Studio version : 2017 Community
Xamarin.Forms version : v2.5.0.121934
Android SDK : usually 8.0 (Oreo)

As there are troubles with Oneplus 3, Oreo 8.0 and Xamarin/Visual Studio at the moment, I also have to uncheck the "Shared runtime" or deploy will fail with a "Please uninstall Debug.Runtime [...]", but it causes no problem since I manually uninstall my app each time I want to re-deploy it. I don't think this behaviour is linked to my initial issue because it also occurs on emulator with "Shared Runtime" enabled, but I thought it would be usefull to still talk about it.

If someone has similar troubles and/or an idea how to fix it...

Thanks for help.

Edit : code sample

[assembly: ExportRenderer(typeof(ObjectToBeRendered), typeof(ObjectToBeRenderedRenderer))] namespace MyNamespace { public class ObjectToBeRenderedRenderer : BaseRenderer { .... } }

Posts

  • leeyoleeyo USMember ✭✭
    edited December 2017

    Well, it gets even weirder... I gave another try on a blank project, and my ListView custom renderer went to work. After another bit of reading, I came to manually delete the bin/obj folders and now the custom renderer works like a charm in my main project. So erm, I guess deleting the bin/obj folders is always a good starting point.

Sign In or Register to comment.