通過查看StackOverflow這個問題似乎被問了很多,但我已經嘗試了所有列出的,似乎無法讓他們任何工作。NHibernate與Windows應用程序
我目前正嘗試在.NET 4.0中用C#編寫的Windows應用程序中使用NHibernate。我目前的平臺目標是x86,並且我已確認我正在使用x86 System.Data.SQLite,並且已將其設置爲在本地複製。我目前的操作系統是Windows 7 x64。
我也有一個大會,是使用NHibernate和談判與數據庫中的一個,它是當我嘗試打電話到它,我得到以下錯誤:
************** Exception Text **************
NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.SQLite20Driver. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> NHibernate.HibernateException: The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
at NHibernate.Driver.SQLite20Driver..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
--- End of inner exception stack trace ---
at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
at NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings)
at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings)
at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
at NHibernate.Cfg.Configuration.BuildSettings()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at Surrix.Cerberus.YouthData.Respositories.NHibernateHelper.get_SessionFactory() in D:\development\Cerberus\YouthData\Respositories\NHibernateHelper.cs:line 20
at Surrix.Cerberus.YouthData.Respositories.NHibernateHelper.OpenSession() in D:\development\Cerberus\YouthData\Respositories\NHibernateHelper.cs:line 29
at Surrix.Cerberus.YouthData.Respositories.YouthRepository.GetYouthByLastName(String lastName) in D:\development\Cerberus\YouthData\Respositories\YouthRepository.cs:line 41
at Surrix.Cerberus.YouthCheckinUI.YouthCheckinMainForm.searchButton_Click(Object sender, EventArgs e) in D:\development\Cerberus\YouthCheckinUI\YouthCheckinMainForm.cs:line 31
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我不能似乎弄清楚在這裏要做什麼。如果有人遇到過此問題,請協助。
下面是我的Hibernate Config文件。
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">
Data Source=D:\\development\\cerberus\\test.s3db;Version=3
</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="query.substitutions">true=1;false=0</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
我很同意,軟件工程正在成爲一個黑匣子魔法,你需要知道的「食譜」,並不再軟件工程原則:(。這些框架通常並不能解釋所有的插件和配置出局,似乎他們想讓大師們爲他們的推廣編寫和出售書籍:) – user310291 2010-09-19 07:58:39