1

I’m trying to upgrade my project from wix v3 to wix v4.

The wix project are as follow :

  • A wix setup
  • A wix bundle
  • A wpf .net 6 class library managed bootstaper

I followed this example https://github.com/wixtoolset/Bal.wixext/tree/master/src/test/examples/WPFCoreMBA and this doc https://wixtoolset.org/docs/development/wips/modify-burn-api/

When I publish the boostraper project, build the bundle and launched it I get this log and errors. How can I fix that ?

[0DA8:0DB4][2023-01-02T18:23:27]e000: Error 0x80131522: Failed to create delegate 
through GetFunctionPointer.
[0DA8:0DB4][2023-01-02T18:23:27]e000: Error 0x80131522: Failed to create the .NET Core 
bootstrapper application factory.
[0DA8:0DB4][2023-01-02T18:23:27]e000: Error 0x80131522: Failed to create BA.
[0DA8:0DB4][2023-01-02T18:23:27]e000: Error 0x80131522: Failed to load BA.
[0DA8:0DB4][2023-01-02T18:23:27]e000: Error 0x80131522: Failed while running

The bundle.wxs

<BootstrapperApplication>
    <Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\LanguageSelector.dll" Name="LanguageSelector.dll" bal:BAFactoryAssembly="yes" />
    <Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\LanguageSelector.deps.json" Name="LanguageSelector.deps.json"/>
    <Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\LanguageSelector.runtimeconfig.json" Name="LanguageSelector.runtimeconfig.json" />
    <Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\WixToolset.Mba.Core.dll" Name="WixToolset.Mba.Core.dll" />
    <Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\mbanative.dll" Name="mbanative.dll" />
    <Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\GalaSoft.MvvmLight.dll" Name="GalaSoft.MvvmLight.dll" />

    <bal:WixDotNetCoreBootstrapperApplicationHost />

The LanguageSelectorFactory0cs

 [assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(LanguageSelector.LanguageSelectorFactory))]
    namespace LanguageSelector
    {
    using WixToolset.Mba.Core;
    public class LanguageSelectorFactory : BaseBootstrapperApplicationFactory
    {

        private static int loadCount = 0;

        protected override IBootstrapperApplication Create(IEngine engine, 
 IBootstrapperCommand bootstrapperCommand)
        {
            if (loadCount > 0)
            {
                engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)");
            }
            ++loadCount;
            return new LanguageSelector(engine, bootstrapperCommand);
        }
     }
    }
Bob John
  • 63
  • 5

1 Answers1

2

In your project file (.csproj) for bootstrapper application (your custom UI application known as BA) you have to add a reference to WixToolset.Dnc.HostGenerator package using Package manager console:

Install-Package WixToolset.Dnc.HostGenerator -Version 4.0.0-rc.1

Alternatively, make sure you have the required references in the mentioned BA project file:

<ItemGroup>
    <PackageReference Include="WixToolset.Mba.Core" Version="4.0.0-rc.1" />
    <PackageReference Include="WixToolset.Dnc.HostGenerator" Version="4.0.0-rc.1" />
</ItemGroup>

The managed BA assembly targeting .NET 6 or later requires WixToolset.Dnc.HostGenerator. Dnc is the abbreviation for Dot Net Core.

Once you have all this set, build and published you have to ensure the entire project output goes to Wix Payload. Including WixToolset.Mba.Core.dll and mbanative.dll. So, your Bundle.wxs have to include these DLLs. In your case should be something like:

<Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\mbanative.dll" />
<Payload SourceFile="..\LanguageSelector\bin\Release\net6.0-windows\publish\win-x86\WixToolset.Mba.Core.dll" />

It could be a lot of DLLs in the project output. So, I personally use the HarvestDirectory functionality in .wixproj to harvest project output directory as a PayloadGroup section. Let me know if you need more details on this.

Pavel Korsukov
  • 939
  • 11
  • 20