How to pass parameters to the custom action?

后端 未结 2 1267
慢半拍i
慢半拍i 2020-11-27 21:36

I\'m trying to create a custom action with \"Value\" attribute, I want to pass parameters to the C# code (the TARGETDIR and the version).

However, I get an error sta

2条回答
  •  抹茶落季
    2020-11-27 22:22

    Note, you're using Value attribute in the wrong way:

    ...this attribute must be used with the Property attribute to set the property...Source


    Based on the Creating WiX Custom Actions in C# and Passing Parameters article you should:

    1. Create properties with desired values:

      
      
      
    2. Create custom action to set the InstallDir property:

      
      
    3. Create custom action:

      
      
    4. Schedule custom actions for execution during installation process:

      
          
          
          ...
      
      
    5. Access those properties from your custom action as follows:

      [CustomAction]
      public static ActionResult YourCustomAction(Session session)
      {
          // session["InstallDir"]
          // session["Version"]
      }
      

提交回复
热议问题