Wix# Samples\DTF (ManagedCA)\Different Scenarios\ExternalAssembly

May 19, 2016 at 12:17 PM
When I build the equivalent to this sample in visual Studio using the WixSharp Setup template and a class library template for the CustomAction code, it works as long as the CustomAction library targets .NET 3.5, but fails when switched to .NET 4.0.

Note that the WixSharp Setup template includes a default App.Config file with:
<?xml version="1.0" encoding="utf-8"?>
    <supportedRuntime version="v2.0.50727"/></startup>
Deleting the App.Config file doesn't help.
May 19, 2016 at 12:20 PM
Here's my CustomAction.cs file (only source file in CustomAction.dll class library project):
using System;
using System.Windows.Forms;
using Microsoft.Deployment.WindowsInstaller;

namespace CustomAction
    public class CustomActions
        public static ActionResult CustomAction(Session session)
            return ActionResult.Success;

    public class DispalyMessage {
        public static void SayHello() {
            MessageBox.Show("Hello World!", "External Managed CA");
And here's my Program.cs file from the WixSharp Setup project:
using System;
using WixSharp;

namespace WixSharp_Setup3 {
    class Program {
        static public void Main(string[] args) {
            var project = new Project() {
                UI = WUI.WixUI_ProgressOnly,
                Name = "CustomActionTest",

                Actions = new[]
                new ManagedAction("CustomAction")
                    ActionAssembly = @"..\CustomAction\bin\Debug\CustomAction.dll",
                    //RefAssemblies = new []{"DispalyMessage.dll"}

May 20, 2016 at 2:18 AM
My feeling is that it is caused by your "target framework" setting in the project properties.

Instead of guessing about your project details I just created an extra sample that contains two VS projects (msi + CA assembly) and it targets .NET v4.0. The sample is also added to the codebase (<Wix# Samples>\DTF (ManagedCA)\Different Scenarios\ExternalAssembly\DTF (ManagedCA) .NET v4.0.7z).