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
Combobox 如何在WiX中安装时填充组合框?_Combobox_Wix_Wix3 - Fatal编程技术网

Combobox 如何在WiX中安装时填充组合框?

Combobox 如何在WiX中安装时填充组合框?,combobox,wix,wix3,Combobox,Wix,Wix3,编辑:多亏了Rob的回答,我已经更新了下面的代码,现在可以使用了。 我已经找到了几个页面,展示了如何做到这一点(,),并查看了WAI()的源代码,但无论我如何尝试,我似乎都无法让它在我的安装程序中工作。如果有人能发现我做错了什么,我将非常感激。对话的WiX片段如下所示: <UI> <Dialog> ...snip... <Control Id="WebsiteName" Type="ComboBox" ComboList="yes" Sorted="

编辑:多亏了Rob的回答,我已经更新了下面的代码,现在可以使用了。

我已经找到了几个页面,展示了如何做到这一点(,),并查看了WAI()的源代码,但无论我如何尝试,我似乎都无法让它在我的安装程序中工作。如果有人能发现我做错了什么,我将非常感激。对话的WiX片段如下所示:

<UI>
  <Dialog>

...snip...

    <Control Id="WebsiteName" Type="ComboBox" ComboList="yes" Sorted="yes" Property="IIS_WEBSITENAME" X="20" Y="73" Width="150" Height="17"/>

...snip...

    <!-- We want our custom action to fill in the WebsiteName ComboBox above
         however, if no ComboBox entries exist at compile time then the
         ComboBox table is not created in the MSI and we can't add to it in
         the custom action. So we have this hidden dummy list box to force
         the table to appear. -->
    <Control Id="DummyComboBox" Hidden="yes" Type="ComboBox" Sorted="yes" ComboList="yes" Property="DUMMYPROPERTY" X="65" Y="60" Width="150" Height="18">
      <ComboBox Property="DUMMYPROPERTY">
        <ListItem Text="Dummy" Value="Dummy"/>
      </ComboBox>
    </Control>
  </Dialog>
</UI>

<Property Id="DUMMYPROPERTY">Dummy</Property>
<Property Id="IIS_WEBSITENAME"/>
<CustomAction Id="FillWebsiteNameList" BinaryKey="WiXCustomAction.dll" DllEntry="FillWebsiteNameList" Execute="immediate" />
<InstallUISequence>
  <Custom Action="FillWebsiteNameList" After="CostFinalize"/>
</InstallUISequence>
过去有两个问题:

1) 上面的代码在运行自定义操作期间失败,其中包含“函数在执行期间失败。数据库:表更新失败”-这是因为索引问题导致代码尝试将字符串写入int列

2) 如果我换线

lRecord.SetString(2, lWebsiteName);

然后查看跟踪,该操作似乎成功,但当安装程序运行时,组合框没有可供选择的条目

<如果我改变组合框有硬编码的值,所有的工作都很好,即使我硬编码LWebStistNeNe.I/P > < P>我不使用DTF(所有的C++),但是记录是1的。您是否尝试将所有SetRecord()调用移到一个索引上


另外,上面的.wxs代码似乎表明您正在使用“DUMMYPROPERTY”作为组合框的控件属性,而不是像.cs代码那样使用“IIS\U WEBSITENAME”。

这一个非常旧,但是我有类似的问题,希望与大家分享我的发现,也许这可以节省一些人的时间

要确保使用EnsureTable创建ComboBox表,请确保CA不会覆盖定义的值:

我从其他函数调用它(称为自定义操作),如下所示:

<UI>
  <Dialog>

...snip...

    <Control Id="WebsiteName" Type="ComboBox" ComboList="yes" Sorted="yes" Property="IIS_WEBSITENAME" X="20" Y="73" Width="150" Height="17"/>

...snip...

    <!-- We want our custom action to fill in the WebsiteName ComboBox above
         however, if no ComboBox entries exist at compile time then the
         ComboBox table is not created in the MSI and we can't add to it in
         the custom action. So we have this hidden dummy list box to force
         the table to appear. -->
    <Control Id="DummyComboBox" Hidden="yes" Type="ComboBox" Sorted="yes" ComboList="yes" Property="DUMMYPROPERTY" X="65" Y="60" Width="150" Height="18">
      <ComboBox Property="DUMMYPROPERTY">
        <ListItem Text="Dummy" Value="Dummy"/>
      </ComboBox>
    </Control>
  </Dialog>
</UI>

<Property Id="DUMMYPROPERTY">Dummy</Property>
<Property Id="IIS_WEBSITENAME"/>
<CustomAction Id="FillWebsiteNameList" BinaryKey="WiXCustomAction.dll" DllEntry="FillWebsiteNameList" Execute="immediate" />
<InstallUISequence>
  <Custom Action="FillWebsiteNameList" After="CostFinalize"/>
</InstallUISequence>
var ComboBoxProperty='RS_INSTANCES';
变量InstanceFullName;
对于(i=0;i
注意:我从上一个函数中删除了不相关的代码片段,以使其可读。 注意:始终(我的意思是始终)使用空、零长度和错误检查,尝试/捕获并确保使用以下内容进行日志记录:

<UI>
  <Dialog>

...snip...

    <Control Id="WebsiteName" Type="ComboBox" ComboList="yes" Sorted="yes" Property="IIS_WEBSITENAME" X="20" Y="73" Width="150" Height="17"/>

...snip...

    <!-- We want our custom action to fill in the WebsiteName ComboBox above
         however, if no ComboBox entries exist at compile time then the
         ComboBox table is not created in the MSI and we can't add to it in
         the custom action. So we have this hidden dummy list box to force
         the table to appear. -->
    <Control Id="DummyComboBox" Hidden="yes" Type="ComboBox" Sorted="yes" ComboList="yes" Property="DUMMYPROPERTY" X="65" Y="60" Width="150" Height="18">
      <ComboBox Property="DUMMYPROPERTY">
        <ListItem Text="Dummy" Value="Dummy"/>
      </ComboBox>
    </Control>
  </Dialog>
</UI>

<Property Id="DUMMYPROPERTY">Dummy</Property>
<Property Id="IIS_WEBSITENAME"/>
<CustomAction Id="FillWebsiteNameList" BinaryKey="WiXCustomAction.dll" DllEntry="FillWebsiteNameList" Execute="immediate" />
<InstallUISequence>
  <Custom Action="FillWebsiteNameList" After="CostFinalize"/>
</InstallUISequence>
函数显示消息(文本、选项){
如果(选项==null){
var options=msiMessageTypeUser;
}
var oRecord=Session.Installer.CreateRecord(1);
oRecord.StringData(1)=文本;
var response=Session.Message(选项、oRecord);
oRecord.ClearData();
oRecord=null;
响应=空;
}

谢谢,我曾经尝试过基于1的代码,但是我已经尝试了很多东西,我可能没有用这段代码做到这一点!我再试一次。我在第二个隐藏的组合控件中使用DUMMYPROPERTY来确保创建ComboBox表,我将尝试将它指向与实际控件相同的属性,看看这是否有任何作用。这是索引(解释了这两个问题)。再次感谢。那么安装程序必须以管理员身份运行?或者,在尝试获取网站列表时,如何避免访问被拒绝?它必须以管理员身份运行。喜欢解决那个问题。
<EnsureTable Id="ComboBox"/>
<Property Id="RS_INSTANCES" Secure="yes"/>
<CustomAction Id="GetRSintances" BinaryKey="JSCommon" Return="ignore"
              JScriptCall="GetRSintances" Execute="immediate" />

<InstallUISequence>
  <Custom Action="GetRSintances" After="AppSearch">
    <![CDATA[NOT Installed AND NOT RS_INSTANCES]]>
  </Custom>
</InstallUISequence>

<InstallExecuteSequence>
  <Custom Action="GetRSintances" After="AppSearch">
    <![CDATA[NOT Installed AND NOT RS_INSTANCES]]>
  </Custom>
</InstallExecuteSequence>

 <!-- UI part -->
 <Control Id="ComboBox1" Type="ComboBox" X="20" Y="160" Width="100" Height="20" Property="RS_INSTANCES" Sorted="yes" >
    <ComboBox Property="RS_INSTANCES">
      <!-- dynamicly filled during installation -->
    </ComboBox>
  </Control>