jeudi 17 mars 2016

Activator.CreateInstance, : Constructor on type 'Pastel.Evolution.PurchaseOrder' not found

I have now gotten to the point where I am trying to create an instance of a class in the assembly I have loaded.

 object obj= Activator.CreateInstance(purchaseOrder,
                                        BindingFlags.NonPublic |
                                        BindingFlags.Instance,
                                        null, new object[] { purchaseOrderDocumentBase }, null);

I keep getting the Error :

An unhandled exception of type 'System.MissingMethodException' occurred in mscorlib.dll Additional information: Constructor on type 'Pastel.Evolution.PurchaseOrder' not found.

What I read up already:

Most of the people are referring to the constructors being private. The type I am loading has 4 constructors all public. Some refer to the Type not having a default constructor, which I thing is the problem.

I have tried to Invoke the first Constructor which has no parameters :

constractor.Invoke(purchaseOrder, null);

I then get the following error.

An unhandled exception of type 'System.Reflection.TargetException' occurred in mscorlib.dll Additional information: Object does not match target type.

Can anyone shed some light on this please.

Thank you in advance.





Aucun commentaire:

Enregistrer un commentaire