using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Snphk.App.Common;
using AppCommon;
using Snphk.App.DDM.BasicInfo;
using System.Runtime.Serialization;
using System.Reflection;namespace Snphk.App.DDM.AcceptHailOil
{
    public partial class DDM_HairOilLine : IValid, IEntity
    {
        public DDM_HairOilLine GetEntityClone()
        {
            DDM_HairOilLine rtnHairOilLine = new DDM_HairOilLine();
            PropertyInfo[] entityPropertiesCopy = rtnHairOilLine.GetType().GetProperties();
            PropertyInfo[] entityProperties = this.GetType().GetProperties();
            foreach (PropertyInfo pi in entityPropertiesCopy)
            {
                for (int i = 0; i < entityProperties.Length; i++)
                {
                    if (pi.Name == entityProperties[i].Name)
                    {
                        pi.SetValue(null, entityProperties[i].GetValue(this, null), null);
                        break;
                    }
                }
            }
            return rtnHairOilLine;        }
    }
}这一句总出错pi.SetValue(null, entityProperties[i].GetValue(this, null), null);
“报错:System.ArgumentException: 未找到属性设置方法。”
调用方式:hoCopy = hairOilLineTemp.GetEntityClone();
hoCopy 为未赋值DDM_HairOilLine类型 对象,hairOilLineTemp为源
DDM_HairOilLine类型 对像
-----------------请问这个问题是怎么回事,该怎么解决!

解决方案 »

  1.   

    pi.SetValue(rtnHairOilLine, entityProperties[i].GetValue(this, null), null); 
      

  2.   

    try:
    pi.SetValue(rtnHairOilLine, entityProperties[i].GetValue(this, null), null); 
      

  3.   

    pi.SetValue(null, entityProperties[i].GetValue(this, null), null); object=null?那你想给哪个对象设置这个属性啊
      

  4.   

    propertyInfo.SetValue(目标对象,entityProperties[i].GetValue(this, null), null); propertyInfo.SetValue(rtnHairOilLine ,entityProperties[i].GetValue(this, null), null);