below code is throwing an exception. please help me with fixing this issue.
namespace ConsoleApp2
{
public class Test
{
public Test()
{
Test1test = new Test1();
}
public int Id { get; set; }
public string Name { get; set; }
public Test1 Test1test { get; set; }
}
public class Test1
{
public Test1()
{ }
public int Id { get; set; }
public string Name { get; set; }
}
class Program
{
static void Main(string[] args)
{
Test t1 = new Test();
Test1 t = new Test1();
typeof(Test1).GetProperty("Name").SetValue(t, "tetst");
var c = Activator.CreateInstance(typeof(Test).GetProperty("Test1test").GetType()); // throwing error
typeof(Test).GetProperty("Test1test").SetValue(c, t);
Console.Read();
}
}
}
System.MissingMethodException: 'Constructor on type 'System.Reflection.RuntimePropertyInfo' not found.'
Aucun commentaire:
Enregistrer un commentaire