1

I'm having a little trouble figuring out why I can't do property injection in a ViewController in a Xamarin iOS app.

My types are registered and they resolve correctly in my ViewController constructor by using this code:

myService = TinyIoCContainer.Current.Resolve<IMyService>();

But instead of assigning all deps manually, I believe I should be able to have TinyIoC "fill up" my ViewController's public properties by using:

TinyIoCContainer.Current.BuildUp (this);

in the constructor of my ViewController, but as soon as I try to run this line of code, even without any public properties specified on my ViewController - I get a stackoverflow exception and a whole lot of errors following that.

Can anyone tell me what I might be doing wrong here?

Claus
  • 1,975
  • 18
  • 24
  • Show the exact exception. – dbugger Jul 13 '14 at 14:49
  • The exception is a System.Reflection.TargetInvocationException. I've tried debugging a bit and have come to the conclusion that it seems like TinyIoC is trying to inject some properties that are inherited from UIViewController class. By adding a [Inject] attribute to the specific properties I would like to have it handle, and then modifying TinyIoC to only inject to properties with this attribute, I actually have a working BuildUp() method now - which also supports my suspicion on TinyIoC failing on some attributes from the UIViewController class. – Claus Jul 13 '14 at 15:37
  • 1
    However, if anyone know if this can be solved somehow other than by this method, I would be very pleased! – Claus Jul 13 '14 at 15:42

0 Answers0