【发布时间】:2014-03-17 10:25:47
【问题描述】:
我在尝试使用 WindowsInstaller 库或 Wix Microsoft.Deployment.WindowsInstaller 时遇到了一些问题。
我遇到了该进程正在使用的文件的异常,即使我已经关闭了所有记录、视图和数据库并处理了它们,我也无法删除它。
try
{
string currentDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
string msiPath = "PathTo\MyMSI.msi";
using (InstallPackage installPackage = new InstallPackage(msiPath, DatabaseOpenMode.ReadOnly))
{
string query = "SELECT * FROM Property WHERE Property = 'ProductVersion'";
using (View view = installPackage.OpenView(query))
{
view.Execute();
using (Record record = view.Fetch())
{
string version = record.GetString(2);
Console.WriteLine(version);
record.Close();
}
view.Close();
}
installPackage.Close();
}
File.Delete(msiPath);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
我仍然得到以下信息:
对路径“PathTo\MyMSI.msi”的访问被拒绝。
我也试过这个对象
数据库
任何帮助将不胜感激。
【问题讨论】:
-
一切似乎都井然有序。您使用的是什么版本的 WiX?
-
@Christopher Painter 您好,感谢您的回复。我正在使用 Wix 3.8。我相信它是最新的
标签: c# database view wix windows-installer