[mono-android] possible linker issue with IoC

Geoff Norton gnorton at novell.com
Mon Mar 14 14:28:02 EDT 2011


Yes it is, you will need to put the [Preserve] attribute on methods you want to call solely thru refleciton.

-g

On 2011-03-14, at 2:20 PM, Matthew Groves wrote:

> I'm using an IoC container to wire up dependencies.  If I wire them up like so:
> 
> MyIoC.Register<IWhatever, Whatever>()
> 
> Then the IoC container is unable to find a constructor at runtime (via GetContructors using reflection).
> 
> However, if I register like so:
> 
> MyIoC.Register<IWhatever>(() => new Whatever(...potentially long series of dependencies...));
> 
> Then it works fine.
> 
> So my question: is this because of the linker?  In the first example, the constructor would only be used via Reflection, and thus the linker could overlook it and exclude the constructor?  If so, is there a way to tell the linker to always include the constructors, or some other workaround?
> 
> Thanks,
> 
> Matt
> 
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
> 
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid



More information about the Monodroid mailing list