InstantiateInstance picks internal constructors

Sep 29, 2012 at 9:36 PM

I just run into an issue where InstantiateInstance picks non-public constructor for instance creation because it has more parameters. Is that supposed behavior? I would expect that only public constructors will be used by default (with option to use non-public per registration).

Coordinator
Oct 1, 2012 at 1:48 AM

bugger. the reflection cheese has properly moved from .NET - I must be calling this bit wrong, sorry.

 

Will have a look at it. Cheers,

Coordinator
Oct 1, 2012 at 10:34 AM

There's a lesson for younger players here: TypeInfo.GetDeclaredMethods and TypeInfo.GetDeclaredProperties both return the *public* Methods/Properties available for the type. TypeInfo.GetDeclaredConstructors, however return all available constructors.

 

Obviously.

 

Thanks for picking this up - it's fixed now :)