Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在自定义操作期间从WiX检索变量_C#_Wix - Fatal编程技术网

C# 在自定义操作期间从WiX检索变量

C# 在自定义操作期间从WiX检索变量,c#,wix,C#,Wix,我试图在安装期间从WiX检索一个变量。以下是我尝试过的测试: try { string reqid = session["REQUESTID"]; TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: Straight Session is valid"); } catch { TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: Str

我试图在安装期间从WiX检索一个变量。以下是我尝试过的测试:

try
{
    string reqid = session["REQUESTID"];
    TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: Straight Session is valid");
}
catch
{
    TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: Straight Session is invalid");
}
try
{
    string reqid = session.CustomActionData["REQUESTID"];
    TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: CustomActionData is valid");
}
catch
{
    TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: CustomActionData is invalid");
}
try
{
    string reqid = session.GetProductProperty("REQUESTID");
    TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: GetProductProperty is valid");
}
catch
{
    TraceLog.LogMessage("CustomAction => ReportUpgradeStatus: GetProductProperty is invalid");
}
我在Product.wxs中有一些xml,例如:

<InstallExecuteSequence>
  <Custom Action="SetRequestIdProp" Before="InstallFiles" />  
  <Custom Action="ReportUpgradeStatusMVACA" After="SetRequestIdProp" />    
  <ScheduleReboot After="InstallFinalize"/>
</InstallExecuteSequence>

<Fragment>
  <Binary Id="CustomActionBinary" SourceFile="..\..\..\Bin\$(var.Configuration)\InstallationCA.CA.dll"/>    
  <Property Id="REQUESTID" Value="[REQUESTID]" />   
  <CustomAction Id="SetRequestIdProp" Property="REQUESTID" Value="[REQUESTID]" />    
  <CustomAction Id="ReportUpgradeStatusMVACA" 
              BinaryKey="CustomActionBinary" 
              DllEntry="ReportUpgradeStatusMVA" 
              Execute="commit" 
              Return="check" />
</Fragment>

谢谢您的帮助。

您的自定义操作是提交自定义操作(我想知道为什么-这很不寻常)。这意味着它也是延迟的,所以您需要通过CustomActionData传递数据,这似乎是一个很好的解释:


调用检索会话[“REQUESTID”]的代码的自定义操作在哪里?我希望看到一个CustomAction Id,它引用了您添加到二进制表中的Dll。@PhilDW我编辑了它。实际上,我继承了一个很大的烂摊子,以前从未处理过WiX(来自一个纯webapp背景)。我是否应该将其更改为延迟?提交自定义操作无法撤消,这就是问题所在。更正常的方法是在执行序列中有意义的某个点将其设置为延迟自定义操作,例如,如果它取决于文件是否存在,则在InstallFiles之后执行,如果它正在调节系统以进行安装,则在更早的时间执行。在CA之前,还应该有一个回滚自定义操作序列,以便在安装失败并回滚时撤消它所做的任何操作,即将系统恢复到其早期状态,就像安装从未启动一样。
<CustomAction Id="SetRequestIdProp" 
              Property="ReportUpgradeStatusMVACA" 
              Value="REQUESTID=[REQUESTID];APPLIANCEID=[APPLIANCEID];SERVICEURL=[SERVICEURL];STATUSDIR=[STATUSDIR];AUTOUPDATE=[AUTOUPDATE]" />
<CustomAction Id="ReportUpgradeStatusMVACA" 
              BinaryKey="CustomActionBinary" 
              DllEntry="ReportUpgradeStatusMVA" 
              Execute="deferred" 
              Return="check"
              HideTarget="no" />
<Custom Action="SetRequestIdProp" Before="ReportUpgradeStatusMVACA" />
<Custom Action="ReportUpgradeStatusMVACA" Before="InstallFinalize" />
RequestId = Int32.Parse(session.CustomActionData["REQUESTID"]),
ApplianceId = Int32.Parse(session.CustomActionData["APPLIANCEID"]),
ServiceUrl = session.CustomActionData["SERVICEURL"],