未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
行 13:     public class OnlineJob : ModelBase
行 14:     {
行 15:         public OnlineJob()
行 16:             : base()
行 17:         {
 
堆栈跟踪: 
[NullReferenceException: 未将对象引用设置到对象的实例。]
   Model.ModelBase..ctor() +485
   ABC.OnlineJob..ctor() in f:\fskenen\App_Code\OnlineJob.cs:15[TargetInvocationException: 调用的目标发生了异常。]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.Activator.CreateInstance() +111
   Model.ObjectFactory.GetObject(String keyValue) +150
   Admin_OnlineJobDetail.Page_Load(Object sender, EventArgs e) in f:\fskenen\Admin\OnlineJobDetail.aspx.cs:15
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627 

解决方案 »

  1.   

    都null了那就看看那儿为null了啊 光这样说没人能帮的了你
      

  2.   

    一般这种错误就是因为哪个地方等于null了,你下断点就能看到
      

  3.   

    你取得的值肯定是Null,你自己调试一下吧!
      

  4.   

    这是全代码
    using System;
    using System.Text;
    using System.Data;
    using System.Collections.Generic;
    using Helper;
    using Model;/// <summary>
    ///OnlineJob 的摘要说明
    /// </summary>
    namespace ABC
    {
        public class OnlineJob : ModelBase
        {
            public OnlineJob()
                : base()
            {
                this._KeyName = "ID";
                this.FileColumns = null;
            }
            public string Job
            {
                get
                {
                    return this.MyRow["Job"].ToString();
                }
                set
                {
                    this.MyRow["Job"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string ContactAddress
            {
                get
                {
                    return this.MyRow["ContactAddress"].ToString();
                }
                set
                {
                    this.MyRow["ContactAddress"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public DateTime CreateTime
            {
                get
                {
                    return Convert.ToDateTime(this.MyRow["CreateTime"]);
                }
                set
                {
                    this.MyRow["CreateTime"] = (value != null) ? value.ToString("yyyy-MM-dd") : DateTime.Now.ToString("yyyy-MM-dd");
                }
            }
            public string Detail
            {
                get
                {
                    return this.MyRow["Detail"].ToString();
                }
                set
                {
                    this.MyRow["Detail"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Email
            {
                get
                {
                    return this.MyRow["Email"].ToString();
                }
                set
                {
                    this.MyRow["Email"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public int ID
            {
                get
                {
                    return Convert.ToInt32(this.MyRow["ID"]);
                }
                set
                {
                    this.MyRow["ID"] = value.ToString();
                }
            }
            public string Phone
            {
                get
                {
                    return this.MyRow["Phone"].ToString();
                }
                set
                {
                    this.MyRow["Phone"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Census
            {
                get
                {
                    return this.MyRow["Census"].ToString();
                }
                set
                {
                    this.MyRow["Census"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            //public DateTime ReplyTime
            //{
            //    get
            //    {
            //        return Convert.ToDateTime(this.MyRow["ReplyTime"]);
            //    }
            //    set
            //    {
            //        this.MyRow["ReplyTime"] = (value != null) ? value.ToString("yyyy-MM-dd") : DateTime.Now.ToString("yyyy-MM-dd");
            //    }
            //}
            public int Status
            {
                get
                {
                    return Convert.ToInt32(this.MyRow["Status"]);
                }
                set
                {
                    this.MyRow["Status"] = value.ToString();
                }
            }
            public string Professional
            {
                get
                {
                    return this.MyRow["Professional"].ToString();
                }
                set
                {
                    this.MyRow["Professional"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public int TypeID
            {
                get
                {
                    return Convert.ToInt32(this.MyRow["TypeID"]);
                }
                set
                {
                    this.MyRow["TypeID"] = value.ToString();
                }
            }
            public bool Visible
            {
                get
                {
                    return this.MyRow["Visible"] != "0";
                }
                set
                {
                    this.MyRow["Visible"] = (value != null && value) ? "1" : "0";
                }
            }
            public bool IsMan
            {
                get
                {
                    return this.MyRow["IsMan"] != "0";
                }
                set
                {
                    this.MyRow["IsMan"] = (value != null && value) ? "1" : "0";
                }
            }
            public bool IsMarried
            {
                get
                {
                    return this.MyRow["IsMarried"] != "0";
                }
                set
                {
                    this.MyRow["IsMarried"] = (value != null && value) ? "1" : "0";
                }
            }
           
            public string YourName
            {
                get
                {
                    return this.MyRow["YourName"].ToString();
                }
                set
                {
                    this.MyRow["YourName"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Graduation
            {
                get
                {
                    return this.MyRow["Graduation"].ToString();
                }
                set
                {
                    this.MyRow["Graduation"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Other
            {
                get
                {
                    return this.MyRow["Other"].ToString();
                }
                set
                {
                    this.MyRow["Other"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string WorkExperience
            {
                get
                {
                    return this.MyRow["WorkExperience"].ToString();
                }
                set
                {
                    this.MyRow["WorkExperience"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Res
            {
                get
                {
                    return this.MyRow["Res"].ToString();
                }
                set
                {
                    this.MyRow["Res"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string School
            {
                get
                {
                    return this.MyRow["School"].ToString();
                }
                set
                {
                    this.MyRow["School"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Height
            {
                get
                {
                    return this.MyRow["Height"].ToString();
                }
                set
                {
                    this.MyRow["Height"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string National
            {
                get
                {
                    return this.MyRow["National"].ToString();
                }
                set
                {
                    this.MyRow["National"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
            public string Bron
            {
                get
                {
                    return this.MyRow["Bron"].ToString();
                }
                set
                {
                    this.MyRow["Bron"] = (value != null) ? value.Replace("'", "") : string.Empty;
                }
            }
        }
    }
      

  5.   

    类型转换你没有做异常处理哦。
    当你的Convert.ToInt32 参数不是 纯数字的字符串的时候,还是会出现异常的哦。
      

  6.   

    类似“return this.MyRow["ContactAddress"].ToString(); “这样的ToString()方法,
    如果你的这一行这一列的值是Null,也是会报错的!
      

  7.   

    调试下就知道哪里是null了,楼主要学会举一反三,而不是一而再再而三的问这类问题
      

  8.   

    代码中有实例为Null。调试跟踪下看到底是那个。