mercredi 12 août 2015

reflection from a string , can not find the method - c#

I'm doing a method that needs to instantiate the object model automatically . The fact is that it fails to instantiate the object because it says it can not find . But I assure you that the method is present .

Error:

Could not load type 'tbl_customer' from assembly 'DataModules, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

I use this:

string className = "tbl_customer";
string namespaceName = "DataModules";

var myObj = Activator.CreateInstance(namespaceName, className);

else, to test the functionality instance the object directly and this works:

tbl_customer t = new tbl_customer();
String tmp = Type.GetType().toString();

doing so I work , why? I would be dynamic .

var myObj = Activator.CreateInstance(namespaceName, className);

in short, is not the method in DataModules

help me :)





Aucun commentaire:

Enregistrer un commentaire