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

后端 未结 9 2239
一个人的身影
一个人的身影 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:35

    You can use the following overload on CreateInstance:

    public static Object CreateInstance(
        Type type,
        Object[] args
    )
    

    And in your case it'd be (I think):

    var designer = Activator.CreateInstance(
        typeof(DelayCompositeDesigner), 
        new object[] { new DelayComposite(4) } 
    );
    

提交回复
热议问题