title: Wix Custom actions run dll c#
body: <p>I'm using a custom action to run a function from dll, but when I run the msi I built, I get the error:</p>
  
  <p>"There is a problem with this windows installer package. A DLL required for this install to complete could not be run. Contact you support..."</p>
  
  <p>This is what I did:</p>
  
  <pre><code>       &lt;Fragment&gt;
  &lt;UI&gt;
    &lt;Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes"&gt;
  
      &lt;Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;amp;Next"&gt;
        &lt;Publish Event="DoAction" Value="MyCustomAction"&gt;1&lt;/Publish&gt;
        &lt;Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg"&gt;CostingComplete = 1&lt;/Publish&gt;
        &lt;Publish Event="NewDialog" Value="SetupTypeDlg"&gt;ProductID&lt;/Publish&gt;
      &lt;/Control&gt;
      &lt;Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel"&gt;
        &lt;Publish Event="SpawnDialog" Value="CancelDlg"&gt;1&lt;/Publish&gt;
      &lt;/Control&gt;
      &lt;Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" /&gt;
      &lt;Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes"&gt;
        &lt;Text&gt;Please enter your customer information&lt;/Text&gt;
      &lt;/Control&gt;
      &lt;Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" /&gt;
      &lt;Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes"&gt;
        &lt;Text&gt;{\WixUI_Font_Title}Customer Information&lt;/Text&gt;
      &lt;/Control&gt;
      &lt;Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" /&gt;
  
    &lt;Control Id="PlatformCombobox" Type="ComboBox" X="45" Y="127" Width="220" Height="18" ComboList="yes" Sorted="yes" Property="Platform"&gt;
      &lt;ComboBox Property="Platform"&gt;
        &lt;ListItem Value="1" Text="1"/&gt;
        &lt;ListItem Value="2" Text="2 "/&gt;
        &lt;ListItem Value="3" Text="3 "/&gt;
        &lt;ListItem Value="4" Text="4 "/&gt;
      &lt;/ComboBox&gt;
    &lt;/Control&gt;
    &lt;/Dialog&gt;
  &lt;/UI&gt;
      &lt;Property Id="Platform" Value="2" /&gt;
  
      &lt;CustomAction Id='MyCustomAction' BinaryKey='CreateFile' DllEntry='CreateFile'/&gt;
      &lt;Binary Id='CreateFile' SourceFile='SetupDll.dll'/&gt;
  
  
    &lt;/Fragment&gt;
  </code></pre>
  
  <p>As you can see I'm trying to run SetupDll.dll which contains 1 class with 1 function:</p>
  
  <pre><code>using System.IO;
  using Microsoft.Deployment.WindowsInstaller;
  
  namespace SetupDll
  {
      public class Creator
      {
          [CustomAction]
          public static ActionResult CreateFile(Session session)
          {
              File.WriteAllText(@"C:\a.txt", "123");
              return ActionResult.Success;
          }
      }
  }
  </code></pre>
  
  <p>But I dont understand the problem. I placed the resulting SetupDll.dll in every folder of the wix project..</p>
  
  <p>Thank you! </p>