NHibernate.InstantiationException:class must declare a default (no-argument) con
阮家友 2016-04-09 10:01:51 Exception Details: NHibernate.InstantiationException: Object class StudentManage.Model.student_info must declare a default (no-argument) constructorStudentManage.Model.student_info
vs2013,MySql5.0
StudentManage.Model类库里有学生信息类,对应数据库学生表,还有学生表的映射文件hbm.xm.
namespace StudentManage.Model
{
[Serializable]
public class student_info
{
#region 成员变量
private string _No;
private string _name;
private string _sex;
private DateTime _birth;
#endregion
public student_info()
{
}
public student_info(string s_No, string s_name, string s_sex, DateTime s_birth)
{
this._No = s_No;
this._name = s_name;
this._sex = s_sex;
this._birth = s_birth;
}
public virtual string No
{
get { return _No; }
set { _No = value; }
}
public virtual string name
{
get { return _name; }
set { _name = value; }
}
public virtual string sex
{
get { return _sex; }
set { _sex = value; }
}
public virtual DateTime birth
{
get { return _birth; }
set { _birth = value; }
}
}
}
NHibernate的配置文件写在web.config中,根下加了
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="WebApplication1">
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="hbm2ddl.keywords">none</property>
<property name="connection.connection_string">
Database=studentmanage;Data Source=192.168.1.146;User Id=root;Password=;
</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>