Vb.net 如何获取wix vb自定义操作项目的wix属性值?

Vb.net 如何获取wix vb自定义操作项目的wix属性值?,vb.net,properties,wix,Vb.net,Properties,Wix,我为这个&%^&$$问题苦苦挣扎了两个多星期,但它仍然不起作用。我需要用户输入一些数据,这些数据需要发送到我的WixVB自定义操作项目。然而,它永远无法到达它。我目前在WIX中有以下代码: 用户的输入: <Control Id="InputField" Type="Edit" X="20" Y="100" Width="140" Height="18" Property="ValueAdaptionScript" Text="{40}"/> 将DLL添加到安装程序:

我为这个&%^&$$问题苦苦挣扎了两个多星期,但它仍然不起作用。我需要用户输入一些数据,这些数据需要发送到我的WixVB自定义操作项目。然而,它永远无法到达它。我目前在WIX中有以下代码:

用户的输入:

 <Control Id="InputField" Type="Edit" X="20" Y="100" Width="140" Height="18" Property="ValueAdaptionScript" Text="{40}"/>

将DLL添加到安装程序:

    <ComponentGroup Id ="DLL" Directory ="INSTALLFOLDER">
  <Component Id ="StringTransfer" Guid ="{479947FA-C324-411C-9B98-083E79C116CB}">
    <File Id ="StringTransfer" KeyPath="yes" Source="C:\Users\fjansen\Documents\Visual Studio 2015\Projects\String Transfer\Data Transfer\obj\x86\Debug\DataTransfer.CA.dll" />
  </Component>
</ComponentGroup>

指向DLL的自定义操作和二进制文件:

    <Binary Id="StringTransfer" SourceFile="C:\Users\fjansen\Documents\Visual Studio 2015\Projects\String Transfer\Data Transfer\obj\x86\Debug\DataTransfer.CA.dll" />

  <CustomAction
      Id="SetProperties"
      Property="ValueAdaptionScript"
      HideTarget="no"
      Value="[MachineIdNumber]"
    />

  <CustomAction
      Id="ValueAdaptionScript"
      BinaryKey="StringTransfer"
      DllEntry="CustomAction1"
      Execute="deferred"
      Impersonate="no"
      Return="check"
    />

  <InstallExecuteSequence>
    <Custom Action="SetProperties" Before="ValueAdaptionScript" />
    <Custom Action="ValueAdaptionScript" Before="InstallFinalize">NOT REMOVE="ALL"</Custom>
  </InstallExecuteSequence>

不删除=“全部”
在WIX自定义操作项目中,我制作了一个函数来写入一个文件,这样我就可以看到从WIX收到了什么。这只是为了测试值的传递,如果值的传递有效,我会修改代码,让它用用户在.INI文件中的输入替换特定的文本

WIX自定义操作项目的代码:

Imports System.IO
Imports System.Reflection

Public Class CustomActions
    Public Shared Property MachineIdNumber As String
    Public Shared Property ValueAdaptionScript As String

    <CustomAction()>
    Public Shared Function CustomAction1(ByVal session As Session) As ActionResult
        Dim file As System.IO.StreamWriter
        file = My.Computer.FileSystem.OpenTextFileWriter("c:\test.txt", True)
        file.WriteLine("test")
        file.WriteLine(MachineIdNumber)
        file.WriteLine(ValueAdaptionScript)
        file.WriteLine(CustomAction1)
        file.Close()

        Return ActionResult.Success
    End Function

End Class
Imports System.IO
输入系统。反射
公共集体诉讼
公共共享属性MachineIdNumber为字符串
公共共享属性值AdaptionScript作为字符串
公共共享函数CustomAction1(ByVal会话作为会话)作为ActionResult
Dim文件作为System.IO.StreamWriter
file=My.Computer.FileSystem.OpenTextFileWriter(“c:\test.txt”,True)
file.WriteLine(“测试”)
file.WriteLine(MachineIdNumber)
file.WriteLine(ValueAdaptionScript)
file.WriteLine(CustomAction1)
file.Close()文件
返回ActionResult.Success
端函数
末级
当安装程序运行所有这些代码时,我确实会得到一个包含以下内容的文本文件:text和0。第一个是逻辑的,因为我硬编码了它,0是CustomAction1的产物,表示CustomAction已经成功结束。这一切都很好,巴德,我没有得到我想看到的价值

我真的需要这方面的帮助,因为我只是不让它工作,并在这个问题上花了大量的时间。这主要是因为这是我部署安装程序之前的最后一个障碍

提前感谢,


F.J

这里有几点不正确

  • 在UI序列和执行序列之间传递的属性必须全部大写,这意味着它们是公共的。还应首先使用Secure='yes'声明它们

  • 您不在自定义操作代码中声明属性,而是从安装过程中获取它们。如果您的CA是即时的,您可能会说varname=session[“VALIDATIONSCRIPT”]之类的话,但它是延迟的,因此这是一个很好的概述:

  • 设置了延迟CA属性之后,您将使用varname=session[“CustomActionData”]

    这也是:


    先生,你是摇滚明星。这在10分钟内解决了我的问题。我尝试了很多方法和组合,在网上搜索了无数次,巴德在阅读了你提供的信息后,一切都很顺利,工作起来就像一场梦。可惜我只能投一票:)