I wish to create an instance of a class, using a string value. According to what I read here: Activator.CreateInstance Method (String, String) it should work!
public class Foo
{
public string prop01 { get; set; }
public int prop02 { get; set; }
}
//var assName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
var assName = System.Reflection.Assembly.GetExecutingAssembly().GetName().FullName;
var foo = Activator.CreateInstance(assName, "Foo");
Why won't this work? I get the following error:
{"Could not load type 'Foo' from assembly 'theassemblyname, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.":"Foo"}
Aucun commentaire:
Enregistrer un commentaire