gpt4 book ai didi

c# - 在 VirtualBox 中运行时无法恢复 Firebird 数据库

转载 作者:太空宇宙 更新时间:2023-11-03 16:02:06 25 4
gpt4 key购买 nike

我有一个在 VirtualBox VM 中运行的 Windows 7 应用程序。它曾经在使用 System.Diagnostics.Process native 运行时恢复数据库,但几个月前停止了。这是我的代码:

Cursor.Current = Cursors.WaitCursor;
bookConn.Close(); // close the connection

FbRestore restoreSvc = new FbRestore();
restoreSvc.ConnectionString = "User=SYSDBA;Password=masterkey;DataSource=localhost;Database=" + dbPath + ";Pooling=true;";
restoreSvc.BackupFiles.Add(new FbBackupFile(backupFilename, 2048));
restoreSvc.PageSize = 4096;
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
restoreSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);
restoreSvc.Execute();

Cursor.Current = Cursors.Default;

我可以从命令行恢复,但不能从 Windows 应用程序中恢复。有什么想法为什么不呢?

最佳答案

在这里扩展我的评论是一些可以尝试的事情:

首先,尝试进行一些日志记录,我记得在某处读到过一个“已知”错误,您有时需要在该错误中强制执行 verbose=true 请尝试使用以下代码片段:

public void RestoreDatabase(string dbPath)
{
FbRestore restoreSvc = new FbRestore();

restoreSvc.ConnectionString = "User=SYSDBA;Password=masterkey;DataSource=localhost;Database=" + dbPath + ";Pooling=true;";
restoreSvc.BackupFiles.Add(new FbBackupFile(BackupRestoreFile, 2048));
restoreSvc.Verbose = true; // Enable verbose logging
restoreSvc.PageSize = 4096;
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;

restoreSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

restoreSvc.Execute();
}

private void ServiceOutput(object sender, ServiceOutputEventArgs e)
{
Console.WriteLine(e.Message);
}

这应该有望阐明正在发生的事情,因为您应该开始进行一些日志记录。 Execute MAY 立即终止,因此您需要确保您的应用程序不会在备份仍在恢复和写入 ServiceOutput 等时结束.

还值得检查的是,当您运行应用程序时,您是以管理员身份运行的,以确保没有奇怪的 Windows 权限问题。

关于c# - 在 VirtualBox 中运行时无法恢复 Firebird 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20887215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com