jeudi 22 janvier 2015

Assembly.CreateInstance does not call parameterless constructor [on hold]

I am trying to modify a project which calls another class library by using Assembly.CreateInstance. The existing library constructors are called fine (I check with Debug.Writeline() ), but not the new one. Other functions in that library can still be called with the returned instance though.



private BackendPlugIn load_BackendPlugIn(String file) //file is project name
{
object instance = null;
bool still_trying = true;
//Read a file to get assembly
var assembly = AddAssembly(file);
do
{
try
{
instance = assembly.CreateInstance(file);
still_trying = instance == null;
}
catch {
Thread.Sleep(0);
}
}
while (still_trying);
}


I should mention that the called functions can throw exception but can't write to Output console. So maybe the constructor WAS called but I don't know any other means to check beside Debug.WriteLine(), and I stucked at there.






Aucun commentaire:

Enregistrer un commentaire