0

我以前做过一些.Net 应用程序,但这是我第一次使用安装程序。

我的安装程序将一个文件(.esriAddIn 扩展名 - 本质上是一个 zip 存档,执行时由 ESRI 产品解压缩到用户的主目录)到用户的文件系统,然后在安装程序完成后尝试执行该文件。

但是,安装程序在执行时似乎仍在访问我的文件,并且该过程失败并显示消息“...文件可能正在使用...”

我已经尝试在重写的 OnCommitted 函数、Committed 事件处理程序和其他几个地方执行该过程,但没有任何乐趣。

谁能告诉我如何在安装程序不保存文件时执行该文件?

安装程序类当前如下所示:

protected override void OnCommitted(IDictionary savedState)
{
    base.OnCommitted(savedState);

    string installFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
    string addinFile = @"\<<file name>>.esriAddIn";

    System.Diagnostics.Process.Start(installFolder + addinFile);
}

非常感谢任何帮助。

4

1 回答 1

0

如果有人有兴趣确实设法解决了这个问题,并且没有涉及到伟大的掌握。我想我以前从未尝试过这种组合:

public partial class Installer : System.Configuration.Install.Installer
{
    private string m_addInLocation;

    public Installer()
    {
        InitializeComponent();

        this.Committed += new InstallEventHandler(this.onCommit);
    }

    protected override void OnCommitted(IDictionary savedState)
    {
        this.m_addInLocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\<<add-in name>>.esriAddIn";

        // raise the committed event - ensure this happens after add in location has been determined
        base.OnCommitted(savedState);
    }

    private void onCommit(object sender, EventArgs e)
    {
        try
        {
            System.Diagnostics.Process.Start(this.m_addInLocation);
        }
        catch (Exception) { MessageBox.Show("..."); }
    }
}
于 2011-07-07T18:32:01.867 回答