I have a requirement where I have to pass 3 parameters to the c# code for managed code custom action in installshield. Cant give the code. Please someone help me out even with basic way of doing so. Thanks in advance.
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
Take a look at DotNetCoCreateObject. Also see this blog post InstallShield, .NET DLLs and DotNetCoCreateObject().
来源:https://stackoverflow.com/questions/18334234/how-to-pass-parameters-to-custom-action-for-a-managed-code-dll-written-in-c