ここ数日、Castle ActiveRecord 例外のトラブルシューティングを試みています。データベースにアクセスしようとすると、InnerException 値の例外が発生します。"An attempt to attach an auto-named database for file database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
SQL Server Express 2005 データベースに接続しようとしています。学校のコンピューターには SQL Express しか搭載されていないため、他のデータベース オプションはありません。
私の接続設定
hibernate.connection.driver_class
NHibernate.Driver.SqlClientDriver
hibernate.dialect
NHibernate.Dialect.MsSql2005Dialect
hibernate.connection.provider
NHibernate.Connection.DriverConnectionProvider
hibernate.connection.connection_string
Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=database.mdf
AttachDBFilename を絶対パスに設定しても、これは機能しません。ユーザー インスタンスは無効です。データベース ファイルは現在、WinForms クラスと混合されたプロジェクトのルートにあります。
使用時
hibernate.connection.connection_string
Data Source=localhost;Initial Catalog=FinalApp;Integrated Security=True;Pooling=False
私のラップトップでは問題なく実行できますが、学校のコンピューターでは SQL Server 2005 Developer Edition を使用できません。
要求に応じた完全なスタック トレース
Castle.ActiveRecord.Framework.ActiveRecordException was unhandled
Message="Could not perform FindAll for Book"
Source="Castle.ActiveRecord"
StackTrace:
at Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType, Order[] orders, ICriterion[] criteria) in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line 1022
at Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType) in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line 982
at Castle.ActiveRecord.ActiveRecordBase`1.FindAll() in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.Generic.cs:line 333
at CSharpFinal.InventoryMain.InventoryMain_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\InventoryMain.cs:line 36
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at CSharpFinal.Form1.inventoryToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Form1.cs:line 51
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CSharpFinal.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Castle.ActiveRecord.Framework.ActiveRecordException was unhandled
Message="Could not create the schema"
Source="Castle.ActiveRecord"
StackTrace:
at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema() in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:line 212
at CSharpFinal.Form1.reInitializeDatabaseToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Form1.cs:line 65
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CSharpFinal.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException.Message
は"An attempt to attach an auto-named database for file database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."