XLabs IoC resolver being set twice... InvalidOperationException

Hi everyone,

I'm getting a weird behavior with the XLabs Resolver that I can't seem to understand what's happening...

In the OnCreate method of my MainActivity class (PCL project), I'm setting up my XLabs Resolver, registering the IDevice and IMediaPicker interfaces. Here's the code I used:

var container = new SimpleContainer();
            container.Register<IDevice>(t => AndroidDevice.CurrentDevice);
            container.Register<IMediaPicker, MediaPicker>();

Now, this works fine, except when we're getting an InvalidOperationException with the message "IResolver can only be set once. If this was intentional you should call Reset method first.". I checked the source code on github and this clearly happens when we're trying to set the resolver when it's already set. The thing is, I'm only calling this in my OnCreate method, no where else.

Am I missing something on how the activity is created that makes this being called twice ? Now I'll be adding a check to the IsSet method to then call ResetResolver when it is already set, but I'd love to understand what's happening behind.

Thanks in advance,



Sign In or Register to comment.