mardi 23 octobre 2018

Activator.CreateInstance returns null

I have this small piece of code:

public static I CreateInstance<I>(string myClassName) where I : class
{
    Debug.Log("Instance: " + (Activator.CreateInstance(null, myClassName) as I));
    return Activator.CreateInstance(null, myClassName) as I;
}

void Test(string testName)
{
    testName = "TestProvider";
    var data = CreateInstance<IProviderInitializer>(testName).GetProviderInfo();
    Debug.Log("Data: " + data);
}

And the problem is that I get NULL Reference Exception and I have no idea why.





Aucun commentaire:

Enregistrer un commentaire