From 3f583916719eeef598d10a5d4e14ef14f008243b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 11 May 2021 07:36:37 -0700 Subject: Merge Dtf --- .../Dtf/Documents/Guide/Content/caproxy.htm | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/samples/Dtf/Documents/Guide/Content/caproxy.htm (limited to 'src/samples/Dtf/Documents/Guide/Content/caproxy.htm') diff --git a/src/samples/Dtf/Documents/Guide/Content/caproxy.htm b/src/samples/Dtf/Documents/Guide/Content/caproxy.htm new file mode 100644 index 00000000..2ee962d5 --- /dev/null +++ b/src/samples/Dtf/Documents/Guide/Content/caproxy.htm @@ -0,0 +1,74 @@ + + + + Proxy Class for Managed Custom Actions + + + + +
+
+ + + + + +
Managed Libraries for Windows Installer
+
+
+

Proxy for Managed Custom Actions

+
+
+
+

The custom action proxy allows an MSI developer to write + custom actions in managed code, while maintaing all the advantages of type 1 + DLL custom actions including full access to installer state, properties, + and the session database.

+

There are generally four problems that needed to be + solved in order to create a type 1 custom action in managed code:

+
    +
  1. Exporting the CA function as a native entry point callable by + MSI: The Windows Installer engine expects to call a LoadLibrary and + GetProcAddress on the custom action DLL, so an unmanaged DLL needs to implement + the function that is initially called by MSI and ultimately returns the result. + This function acts as a proxy to relay the custom action call into the + managed custom action assembly, and relay the result back to the caller.

    +
  2. Providing supporting assemblies without + requiring them to be installed as files: If a DLL custom + action runs before the product's files are installed, then it is difficult + to provide any supporting files, because of the way the CA DLL is singly + extracted and executed from a temp file. (This can be a problem for + unmanaged CAs as well.) With managed custom actions we have already hit + that problem since both the CA assembly and the MSI wrapper assembly + need to be loaded. To solve this, the proxy DLL carries an appended + cab package. When invoked, it will extract all contents of the + cab package to a temporary working directory. This way the cab package can + carry any arbitrary dependencies the custom action may require.
  3. +
  4. Hosting and configuring the Common Language Runtime: + In order to invoke a method in a managed assembly from a previously + unmanaged process, the CLR needs to be "hosted". This involves choosing + the correct version of the .NET Framework to use out of the available + version(s) on the system, binding that version to the current process, and + configuring it to load assemblies from the temporary working directory.

    +
  5. Converting the integer session handle into a + Session object: The Session class in the managed + wrapper library has a constructor which takes an integer session handle as + its parameter. So the proxy simply instantiates this object before + calling the real CA function.

    +
+

The unmanaged CAPack module, when used in combination with the managed proxy in + the + Microsoft.WindowsInstaller assembly, accomplishes the tasks above to enable + fully-functional managed DLL custom actions.

+


+

See also:

+ +


+
+ + -- cgit v1.2.3-55-g6feb