Activator.CreateInstance can't find the constructor (MissingMethodException)

后端 未结 9 2245
一个人的身影
一个人的身影 2021-02-18 15:55

I have a class which has the following constructor

public DelayCompositeDesigner(DelayComposite CompositeObject)
{
    InitializeComponent();

    compositeObjec         


        
9条回答
  •  迷失自我
    2021-02-18 16:28

    If you want to call this contructor...

    public DelayCompositeDesigner(DelayComposite CompositeObject)
    

    ...just use this:

    var designer = Activator.CreateInstance(typeof(DelayCompositeDesigner), new DelayComposite(4));
    

    or

    var designer = Activator.CreateInstance(new DelayComposite(4));
    

提交回复
热议问题