How to pass parameters to custom action for a managed code dll written in C#?

帅比萌擦擦* 提交于 2019-12-06 09:41:41

Since you mention a custom action, refer to Specifying the Signature for a Managed Method in an Assembly Custom Action. Specify values, or properties that store the values, that you need to pass to the parameters in the function. Note that if this is a deferred custom action, you will need to pass them through CustomActionData as mentioned in the third paragraph "Using a Custom Method Signature for a Deferred, Commit, or Rollback Custom Action."

Windows Installer XML (WiX) Deployment Tools Foundation (DTF) provides a framework for writing managed code custom actions for the Windows Installer. The compiled DLL's appear as standard Win32 DLL's with Type 1 exported functions and is fully compatible with InstallShield.

If it's an immeadiate custom action you simply say:

string someProperty = sessions["SOMEPROPERTY"];

If it's a deferred custom action, you use an immediate custom action to build a CustomActionData class then serialize it to string to be passed to the deferred custom action which then deserializes it back to a CustomActionData class. ( Basically a propery/value dictionary ).

Required background reading is:

Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer

Reasons DTF is Better

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!