Managed UI and external .NET 4 custom actions

Sep 15, 2015 at 3:33 PM

I am trying to build a Managed UI setup and use an external .NET 4 assembly for deferred custom actions. The .NET 4 assembly cannot be converted in .NET 3.5 assembly.

My WixSharp project is .NET 3.5, to be able to use managed UI.

I defined a deferred managed custom action in my project:
 new ElevatedManagedAction("MyMethod", "My_dotNET4CustomActions.dll")
                    RefAssemblies = new []{"My_dotNET4CustomActions.dll"},
When I try to build the WixSharp project, I get the message:
"Could not load file or assembly 'My_dotNET4CustomActions.dll'. This assembly is built by a runtime newer than the currently loaded runtime."

Any suggestion will be appreciated.
Sep 16, 2015 at 6:00 AM
The problem is caused by MakeSfxCA.exe accepting and ignoring the misnamed config file. Thanks WiX team support the fix/work-around became possible.

The latest release v1.0.26.0 allows both EmbeddedUI and Custom Actions to be compiled for .NET 4.0. All ManagedSetup samples are also updated to target .NET 4.0.
Sep 18, 2015 at 9:27 AM
My installer works now. Thanks.

Just 2 notes:
  • In the new version when I set the project.LicenseFile the project does not compile
  • I cannot define 2 virtual directories in the same way, in my project
        ManagedProject project =
                    new ManagedProject("MyProject", 
                        new Dir("MyFirstFolder",
                                new WixSharp.File(Path.Combine(FilesPath, @"WebApi1\Global.asax"),
                                     new IISVirtualDir
                                        Name = "MyWebApp1",
                                        AppName = "MyWebApp1",
                                        WebSite = new WebSite("DefaultWebSite", "*:80", "Default Web Site")
                        new Dir("MySecondFolder",
                                new WixSharp.File(Path.Combine(FilesPath, @"WebApi2\Global.asax"),
                                     new IISVirtualDir
                                        Name = "MyWebApp2",
                                        AppName = "MyWebApp2",
                                        WebSite = new WebSite("DefaultWebSite", "*:80", "Default Web Site")
These are not show stoppers, just I wanted to let you know.
Thank you again for your support.
Sep 18, 2015 at 10:09 AM
Thank you. Yep. It is already reported (in the middle of thread):
The issue #67 has been created.

The problem is caused by the XDocument XML manipulation flaw. The fix currently available only via NuGet: Install-Package WixSharp.bin -Pre
May 19, 2016 at 11:51 AM
Is it necessary to put the same dll in the RefAssemblies array?

What was the misnamed config file? Something Wix# manages internally or something that has to be specified along with the external dll?
May 20, 2016 at 12:47 AM
I am not sure I follow. What do you refer as "same dll"? You can but don't have to put there the dll that implements your custom action (if it's what you are asking about). However you have to add all the dlls that your custom action depends on. Unless of course it depends on standard GAC assemblies only.

> ...misnamed config file:
WiX has this questionable constrain: the config file must be EmbeddedUI.config, not CustomAction.config for EmbeddedUI custom action.
WiX silently allows CustomAction.config currently. An extra validation has been scheduled by WiX team as a feature for the future release.

This was an internal ManagedUI initialization issue and currently Wix# automatically renames your project.CAConfigFile when it detects that the managed CA is in fact an EmbeddedUI initialization routine.