ā Using Activator.CreateInstance() when the constructor has arguments - not finding constructor
I'm trying to create a class instance dynamically using
Activator.CreateInstance()
, and it's crashing and not finding the constructor.
My object looks like this:
And I'm creating it like this:
However, when it hits the CreateInstance()
line, an exception occurs:
Any idea what I'm doing wrong here?5 Replies
it doesn't call private constructors by default
it needs an extra parameter
It should be a public constructor that's available to it, and I'm passing the logger in as a second parameter to
CreateInstance()
it's literally private
in the code above
oh, sorry - that's my mistake when typing up the code in this question
let me check my actual code too
Ah shit, yes - it's private in my actual code
Thanks - silly mistake!
š¤¦āāļø
np