使用 Wise Installer Studio 7.0 时,自定义操作返回实际错误代码 1154
首先,这与解决的问题非常相似 通过 WiX 使用 C# 中的自定义操作失败,并出现错误 1154
但是,我无法辨别在我的情况下解决问题的具体步骤。希望有人能指出我正确的方向。
就我而言,我使用 Wise Installation Studio 7.0 来执行我编写的 C# 自定义操作,以在 Server 2008 R2 及更高版本上启动 .Net Framework 3.5 SP1 的服务器管理器功能。
我在 Visual Studio 2010 中创建了自定义操作作为标准 .Net 2.0 类库。
我的猜测是,我需要在这里做一些不同的事情 - 这需要编译为托管 DLL 之外的东西。我使用的代码相当简单...取自 Flexera 论坛,其中其他人发布了 Server 2008 R2 上 .Net Framework 3.5 SP1 问题的解决方案。
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using Common_Functions;
namespace ActivateDotNetFramework
{
/**
* @brief helper library to activate .Net Framework on certain operating systems
*
* @args None
*
*
* @author Daniel Lee
* @date Jan 17,2012
* @version 1.0
* @bug 6540 Role Management tool required for 2008R2 to install .NET 3.5 SP1
**/
class ActivateDotNetFramework
{
static void Main(string[] args)
{
string logFile = "ActivateDotNetFeatures.log";
WriteToLog logWriter = null;
Process p = null;
ProcessStartInfo startInfo = null;
try
{
logWriter = new WriteToLog(logFile, "");
logWriter.UpdateLog("AMAZINGCHARTS! ActivateDotNetFramework Custom Action");
//open powershell process to activate the .net framework feature. See:
//http://community.flexerasoftware.com/archive/index.php?t-182914.html
startInfo = new ProcessStartInfo();
startInfo.FileName = "powershell.exe";
startInfo.Arguments = "Import-Module ServerManager ; Add-WindowsFeature as-net-framework";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
string sLogMsg = "";
p = new Process();
p.StartInfo = startInfo;
sLogMsg = "ProcessStartInfo Data ... ";
logWriter.UpdateLog(sLogMsg);
sLogMsg = "FileName: " + p.StartInfo.FileName + "\n Arguments:" + p.StartInfo.Arguments;
logWriter.UpdateLog(sLogMsg);
p.Start();
p.WaitForExit();
sLogMsg = "ActivateDotNetFramework Custom Action Return Code: " + p.ExitCode.ToString();
logWriter.UpdateLog(sLogMsg);
}
catch (Exception)
{
throw;
}
finally
{
}
}
}
}
关于如何在 VS2010 中进行此操作有什么想法吗?或者问题出在我的 Wise Installation Studio 包 CA 配置中?据我所知,VS2010 只构建了托管的ActivateDotNetFramework.dll 文件,没有其他任何东西。我将此文件添加到了wise包中的资源中,并将函数名称列为ActivateDotNetFramework。
我已经在这件事上徘徊了一天多了。任何帮助表示赞赏。谢谢。
李丹 惊人的图表! 发布工程师
First of all this is very similar to the issue addressed Custom Action in C# used via WiX fails with error 1154
However, I was not able to discern specific steps to solve the problem in my situation. Hopefully someone can point me in the right direction.
In my case I am using Wise Installation Studio 7.0 to execute a C# custom action I wrote to start the Server Manager Feature for .Net Framework 3.5 SP1 on Server 2008 R2 and newer.
I created the custom action in visual studio 2010 as a standard .Net 2.0 Class Library.
My guess is that I need to do something different here - that this needs to be compiled as something than a managed DLL. The code I am using is fairly straight forward ... taken from the flexera forums where someone else posted a solution to the .Net Framework 3.5 SP1 issue on Server 2008 R2.
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using Common_Functions;
namespace ActivateDotNetFramework
{
/**
* @brief helper library to activate .Net Framework on certain operating systems
*
* @args None
*
*
* @author Daniel Lee
* @date Jan 17,2012
* @version 1.0
* @bug 6540 Role Management tool required for 2008R2 to install .NET 3.5 SP1
**/
class ActivateDotNetFramework
{
static void Main(string[] args)
{
string logFile = "ActivateDotNetFeatures.log";
WriteToLog logWriter = null;
Process p = null;
ProcessStartInfo startInfo = null;
try
{
logWriter = new WriteToLog(logFile, "");
logWriter.UpdateLog("AMAZINGCHARTS! ActivateDotNetFramework Custom Action");
//open powershell process to activate the .net framework feature. See:
//http://community.flexerasoftware.com/archive/index.php?t-182914.html
startInfo = new ProcessStartInfo();
startInfo.FileName = "powershell.exe";
startInfo.Arguments = "Import-Module ServerManager ; Add-WindowsFeature as-net-framework";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = true;
string sLogMsg = "";
p = new Process();
p.StartInfo = startInfo;
sLogMsg = "ProcessStartInfo Data ... ";
logWriter.UpdateLog(sLogMsg);
sLogMsg = "FileName: " + p.StartInfo.FileName + "\n Arguments:" + p.StartInfo.Arguments;
logWriter.UpdateLog(sLogMsg);
p.Start();
p.WaitForExit();
sLogMsg = "ActivateDotNetFramework Custom Action Return Code: " + p.ExitCode.ToString();
logWriter.UpdateLog(sLogMsg);
}
catch (Exception)
{
throw;
}
finally
{
}
}
}
}
Any ideas on how I should proceed with this in VS2010? Or is the issue in my Wise Installation Studio package CA configuration? As far as I can see VS2010 only builds the managed ActivateDotNetFramework.dll file and nothing else. I added this file to my resources in the wise package and listed the function name as ActivateDotNetFramework.
I have been around and around on this for over a day now. Any help is appreciated. Thanks.
Dan Lee
AmazingCharts!
Release Engineer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该代码应编译为 EXE 并作为 EXE 自定义操作运行。但我更大的问题是为什么要这么麻烦呢?在 Windows 中安装功能所需要做的就是调用:
dism /online /Enable-Feature FeatureName
要获取功能名称列表,请键入:
dism /online /Get-Features
That code should be compiled as an EXE and ran as an EXE custom action. But my bigger question is why bother at all? All you have to do in Windows to install a feature is call:
dism /online /Enable-Feature FeatureName
For a list of feature names type:
dism /online /Get-Features