You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wix Toolset v4托管Bootstrapper应用创建失败求助(错误0x80131508)

Wix Toolset v4 托管引导程序应用加载失败(错误0x80131508)

多日寻找Wix Toolset v4的Managed Bootstrapper Application可用示例,大多都是v3版本。目前遇到错误代码0x80131508,日志提示无法创建、加载托管引导程序应用。

安装程序包含基于WPF(.NET Framework)的自定义UI、Wix Toolset v4构建的MSI,通过Bundle生成exe文件。日志报错如下:

Error 0x80131508: Failed to create the bootstrapper application.
Error 0x80131508: Failed to create the managed bootstrapper application.
Error 0x80131508: Failed to create BA.
Error 0x80131508: Failed to load BA.
Error 0x80131508: Failed while running

相关代码文件

UI项目文件

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>    
    <RuntimeIdentifier>win-x86</RuntimeIdentifier>
  </PropertyGroup>
  
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <PlatformTarget>x86</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\x86\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  
  <PropertyGroup>
    <StartupObject />
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.DirectoryServices.AccountManagement" />
    <Reference Include="System.ServiceProcess" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xaml" />
      
  
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <PackageReference Include="Newtonsoft.Json">
      <Version>13.0.3</Version>
    </PackageReference>
    <PackageReference Include="WixToolset.Mba.Core" Version="4.0.*" PrivateAssets="All" GeneratePathProperty="true" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="WixToolset.Mba.Host.config" CopyToOutputDirectory="PreserveNewest" />
    <Content Include="$(PkgWixToolset_Mba_Core)\runtimes\win-x86\native\mbanative.dll">
      <Visible>false</Visible>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      <IsAssembly>false</IsAssembly>
    </Content>
  </ItemGroup>
  <ItemGroup>
    
    <Page Include="AdditionalStyles.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
    <Page Include="MainWindow.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </Page>
   
  </ItemGroup>
</Project>

CustomUI.cs

using System.Windows.Threading;
using WixToolset.Mba.Core;

namespace MyOwnApp
{
   public class CustomUI : BootstrapperApplication
    {
        public CustomUI(IEngine engine) : base(engine)
        {
        }

        public IEngine Engine => this.engine;
        public static Dispatcher BootstrapperDispatcher { get; private set; }

        protected override void Run()
        {
            this.Engine.Log(LogLevel.Verbose, "Launching Custom UI");
            BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

            MainWindow view = new MainWindow(this);
            view.Bootstrapper.Engine.Detect();        
            view.DataContext = view;
            view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
            view.Show();

            Dispatcher.Run();
            this.Engine.Quit(0);
        }

        protected override void OnStartup(StartupEventArgs args)
        {
            base.OnStartup(args);

            this.engine.Log(LogLevel.Standard, nameof(CustomUI));
        }

        protected override void OnShutdown(ShutdownEventArgs args)
        {
            base.OnShutdown(args);

            var message = "Shutdown," + args.Action.ToString() + "," + args.HResult.ToString();
            this.engine.Log(LogLevel.Standard, message);
        }
    }
}

CustomUIFactory.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyOwnApp
{
    using WixToolset.Mba.Core;
    public class CustomUIFactory : 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 CustomUI(engine);
        }
    }
}

WixToolset.Mba.Host.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="wix.bootstrapper" type="WixToolset.Mba.Host.BootstrapperSectionGroup, WixToolset.Mba.Host">
      <section name="host" type="WixToolset.Mba.Host.HostSection, WixToolset.Mba.Host" />
    </sectionGroup>
  </configSections>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
  </startup>
  <wix.bootstrapper>
    <host assemblyName="MyOwnApp" />
  </wix.bootstrapper>
</configuration>

尝试了网上几乎所有示例,但都无法解决问题,恳请帮助。

内容的提问来源于stack exchange,提问作者rikuna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 17:15:58