如何在安装运行之前调用自定义操作 [英] How to call custom action before setup run

查看:66
本文介绍了如何在安装运行之前调用自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是初学者创建Windows应用程序设置。我需要在我的setup.to中添加dot net framework 4.0或sql express 2008来完成此任务我正在使用自定义操作。但是当我运行我的设置时收到错误信息另一个安装过程正在运行。因为我的设置过程中间自动定制动作午餐,但在那个时候我的主要设置也处于运行模式。所以PLZ帮助我。



感谢adv。

i am beginner to create windows application setup. and i have requirement to add dot net framework 4.0 or sql express 2008 in my setup.to done this task i am using custom action. but when i run my setup getting a error msg "Another installation process is running". because of mid of my setup process custom action lunch automatically but on that time my main setup is also in running mode. so plz help me.

thanks in adv.

推荐答案

您不必依赖自定义操作。

在Visual Studio 2008 Standard中有一个对话框可以使用

安装项目 - 属性 - 必需组件

除其他可能外,还有各种暴露.NET框架的版本和(在我的机器上)SQL Server Compact 3.5和SQL Server 2005 Express SP2(x86)。



所以我想,你会发现什么你需要那里。



请记住选择从应用程序的相同位置而不是来自经销商的网站或从这里:......单选按钮部分。否则,您的安装包中将没有包含该内容的数据,而只是链接。





这是代码讨论了将安装程序包包装在另一个应用程序资源中的可能性。实际上这是打开它。这是在包装器应用程序的运行时执行的。

You don't have to rely on custom actions for those.
In Visual Studio 2008 Standard there is a dialogue available using
Setup Project - Properties - Required Components
that, among other possibilities, exposes various versions of the .NET framework and (on my machine) SQL Server Compact 3.5 and SQL Server 2005 Express SP2 (x86).

So I guess, you will find what you need there.

Keep in mind to select "From same location as application" instead of "From distributor's website" or "From here: ..." in the radio button section. Otherwise there will be no data for that stuff packed in your setup package, but just links instead.


Here is code for the discussed possibility to wrap a setup package in another applications resources. Actually this is to unwrap it. This is executed during the wrapper applicaiton's runtime.
// Create a temporary directory to "extract" your setup stuff to
string tempPath = System.IO.Path.GetTempPath();
for (int tempIndex = 0; tempIndex < int.MaxValue; tempIndex++)
{
    string myTempPath = System.IO.Path.Combine(tempPath, tempIndex.ToString());
    if (
        System.IO.Directory.Exists(myTempPath)
        || System.IO.File.Exists(myTempPath)
    )
    {
        continue;
    }
    tempPath = myTempPath;
    break;
}

string setupExePath = null;

// Repeat what is in these braces
//   for all files and directories
//   that are necessary for your setup to work
{
    string fileName = System.IO.Path.Combine(tempPath, "Setup.exe");
    
    // Only for Setup.exe
    setupExePath = fileName;

    using (System.IO.MemoryStream stream = new System.IO.MemoryStream(Properties.Resources.WhatYouCalledYourSetupFileResource))
    {
        System.IO.File.WriteAllBytes(fileName, stream.ToArray());
    }
}

// Execute the original Setup.exe file.
System.Diagnostics.Process.Start(setupExePath);

// Delete the temporary stuff
System.IO.Directory.Delete(tempPath, true);



[/ Edit]


[/Edit]


这篇关于如何在安装运行之前调用自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆