NHbernate2.1.2hibernate-cfg.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernate.Test">
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">
Database=db_nhibernate;Data Source=192.168.1.98;User Id=root;Password=root;pooling=false;CharSet=utf8;port=3306
</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<mapping assembly="NHbernateDemo.Model"/>
</session-factory>
</hibernate-configuration>
加入MySql.Data.dll到bin文件下之后
执行如下代码:
ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory();
异常:
未处理 System.ArgumentNullException
Message="值不能为空。\r\n参数名: stream"
Source="mscorlib"
ParamName="stream"
StackTrace:
在 System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
在 System.IO.StreamReader..ctor(Stream stream)
在 MySql.Data.MySqlClient.SchemaProvider.GetReservedWords()
在 MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
在 MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
在 MySql.Data.MySqlClient.SchemaProvider.GetSchema(String collection, String[] restrictions)
在 MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName, String[] restrictionValues)
在 MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName)
在 NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetReservedWords()
在 NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
在 NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
在 NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
在 NHibernate.Cfg.Configuration.BuildSessionFactory()
在 NHibernateDemo.NHbernateForm.NHbernateForm_Load(Object sender, EventArgs e) 位置 C:\Documents and Settings\chenlei\My Documents\NHibernateDemo\NHibernateDemo\NHibernateDemo\NHbernateForm.cs:行号 23
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 NHibernateDemo.Program.Main() 位置 C:\Documents and Settings\chenlei\My Documents\NHibernateDemo\NHibernateDemo\NHibernateDemo\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
请问是什么原因?
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernate.Test">
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">
Database=db_nhibernate;Data Source=192.168.1.98;User Id=root;Password=root;pooling=false;CharSet=utf8;port=3306
</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<mapping assembly="NHbernateDemo.Model"/>
</session-factory>
</hibernate-configuration>
加入MySql.Data.dll到bin文件下之后
执行如下代码:
ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory();
异常:
未处理 System.ArgumentNullException
Message="值不能为空。\r\n参数名: stream"
Source="mscorlib"
ParamName="stream"
StackTrace:
在 System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
在 System.IO.StreamReader..ctor(Stream stream)
在 MySql.Data.MySqlClient.SchemaProvider.GetReservedWords()
在 MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
在 MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
在 MySql.Data.MySqlClient.SchemaProvider.GetSchema(String collection, String[] restrictions)
在 MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName, String[] restrictionValues)
在 MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName)
在 NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetReservedWords()
在 NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
在 NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
在 NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
在 NHibernate.Cfg.Configuration.BuildSessionFactory()
在 NHibernateDemo.NHbernateForm.NHbernateForm_Load(Object sender, EventArgs e) 位置 C:\Documents and Settings\chenlei\My Documents\NHibernateDemo\NHibernateDemo\NHibernateDemo\NHbernateForm.cs:行号 23
在 System.Windows.Forms.Form.OnLoad(EventArgs e)
在 System.Windows.Forms.Form.OnCreateControl()
在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
在 System.Windows.Forms.Control.CreateControl()
在 System.Windows.Forms.Control.WmShowWindow(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WmShowWindow(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)
在 System.Windows.Forms.Control.set_Visible(Boolean value)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 NHibernateDemo.Program.Main() 位置 C:\Documents and Settings\chenlei\My Documents\NHibernateDemo\NHibernateDemo\NHibernateDemo\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
请问是什么原因?
解决方案 »
- 在C#中,读ini到表中,并可在表中修改这些参数.
- C#中有类似VCL的InputQuery方法或替代方法吗?
- 多线程的问题
- 求个C#写的判断用户输入的是《回文》的代码
- provider 命名管道提供程序 error 40,无法打开sql连接
- 请问谁有网上商店的原代码??如何合适的话,必有重谢
- 如何用C#读取文本,并删掉特定格式或包含某关键字的行?
- 求可編輯的下拉框
- 求助~~~~~~~~~~~在c#中如何上传图片到 sql server中的image字段中!!!! 跪求!~~~~~~
- 关于C#中的打印,
- 如何实现在winform中模拟登陆网站后,浏览器打开该网站为已登录状态
- 求助:如何利用smtp协议接收邮件?
http://topic.csdn.net/u/20070710/13/fd6d4a24-416e-4d45-870b-ec3a3fbbc437.html
private void NHbernateForm_Load(object sender, EventArgs e)
{
ISessionFactory factory = new NHibernate.Cfg.Configuration().Configure().BuildSessionFactory(); ISession session = factory.OpenSession(); }