2011-11-02 71 views
2

我正在嘗試爲WiX和刻錄創建自定義UI。我遵循了我發現的一些指南,到目前爲止,我有一個項目具有以下內容,它從BootstrapperApplication繼承。WiX刻錄自定義UI

namespace MyBA 
{ 
    public class TestBA : BootstrapperApplication 
    { 
     protected override void Run() 
     { 
      MessageBox.Show("My BA is running"); 
      this.Engine.Quit(0); 
     } 
    } 
} 

而在AssemblyInfo.cs中:

[assembly: BootstrapperApplication(typeof(TestBA))] 

然後在我的引導程序的項目,我有以下。

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 

    <Bundle Name="MyApplication" 
      Version="1.0.0" 
      Manufacturer="Acme Ltd" 
      UpgradeCode="F84A4058-FDF6-4218-BCB5-12C811DA3C99" 
      Condition="NOT ((VersionNT = 600 AND ServicePackLevel >=2) OR (VersionNT >= 601))" 
      IconSourceFile="$(var.MyApplicationInstallerRequiredFiles.ProjectDir)logo.ico" 
      SplashScreenSourceFile="$(var.MyApplicationInstallerRequiredFiles.ProjectDir)Splashscreen.bmp" 
      DisableRepair="no" 
      DisableRemove="no" 
      DisableModify="no"> 

     <WixVariable Id="WixMbaPrereqPackageId" 
        Value="Netfx4Full" /> 
     <WixVariable Id="WixMbaPrereqLicenseUrl" 
        Value="NetfxLicense.rtf" /> 

     <WixVariable Id="WixStdbaLicenseRtf" 
        Value="$(var.MyApplicationInstallerRequiredFiles.ProjectDir)Licence.en-gb.rtf" /> 
     <WixVariable Id="WixStdbaLogo" 
        Value="$(var.MyApplicationInstallerRequiredFiles.ProjectDir)logoInstallSmall.bmp" /> 

     <BootstrapperApplicationRef Id='ManagedBootstrapperApplicationHost'> 
      <Payload Name='BootstrapperCore.config' 
        SourceFile='$(var.MyApplicationInstallerRequiredFiles.ProjectDir)Bootstrapper\MyBA.BootstrapperCore.config' /> 
      <Payload SourceFile='$(var.MyApplicationInstallerRequiredFiles.ProjectDir)Bootstrapper\MyBA.dll' /> 
     </BootstrapperApplicationRef> 

     <Chain> 
      <PackageGroupRef Id="MyApplicationPackage" /> 
     </Chain> 
    </Bundle> 
</Wix> 

和我已經加入MyBA.BootstrapperCore.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <configSections> 
     <sectionGroup name="wix.bootstrapper" 
         type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.BootstrapperSectionGroup, BootstrapperCore"> 
      <section name="host" 
        type="Microsoft.Tools.WindowsInstallerXml.Bootstrapper.HostSection, BootstrapperCore" /> 
     </sectionGroup> 
    </configSections> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
     <supportedRuntime version="v4.0" /> 
    </startup> 
    <wix.bootstrapper> 
     <host assemblyName="MyBA"> 
      <supportedFramework version="v4\Full" /> 
      <supportedFramework version="v4\Client" /> 
     </host> 
    </wix.bootstrapper> 
</configuration> 

但是,每當我運行Setup.exe的引導程序,我得到的啓動畫面短暫出現,但沒有別的。如果我在%TEMP%查看日誌有以下

[0A00:0424][2011-11-02T15:52:08]: Burn v3.6.2221.0, path: C:\MyApplication\dev\source\Bootstrapper1\bin\Debug\Setup.exe, cmdline: '' 
[0A00:0424][2011-11-02T15:52:08]: Setting string variable 'WixBundleName' to value 'MyApplication' 
[0A00:0424][2011-11-02T15:52:08]: Setting string variable 'WixBundleLog' to value 'C:\Users\AppData\Local\Temp\MyApplication_20111102155208.log' 
[0A00:0424][2011-11-02T15:52:08]: Condition 'NOT ((VersionNT = 600 AND ServicePackLevel >=2) OR (VersionNT >= 601))' evaluates to true. 
[0A00:0424][2011-11-02T15:52:08]: Setting string variable 'WixBundleOriginalSource' to value 'C:\MyApplication\dev\source\Bootstrapper1\bin\Debug\Setup.exe' 
[0A00:0424][2011-11-02T15:52:08]: Loading managed bootstrapper application. 
[0A00:0424][2011-11-02T15:52:08]: Error 0x80131040: Failed to create the managed bootstrapper application. 
[0A00:0424][2011-11-02T15:52:08]: Error 0x80131040: Failed to create UX. 
[0A00:0424][2011-11-02T15:52:08]: Error 0x80131040: Failed to load UX. 
[0A00:0424][2011-11-02T15:52:08]: Error 0x80131040: Failed while running 
[0A00:0424][2011-11-02T15:52:08]: Error 0x80131040: Failed to run per-user mode. 

爲什麼會這樣,爲什麼正在發生上述錯誤?

回答

7

如果你看一下在WixBA的源代碼,他們宣稱全球Threading.Dispatcher,然後在重寫的run()方法中,存在以下行:

Threading.Dispatcher.Run(); 

我有類似的問題,同樣將Threading.Dispatcher添加到我的引導程序應用程序中修復它們。另外,如果您的引導程序應用程序依賴於任何其他dll,則需要在<BootstrapperApplicationRef/>下將它們包含爲<Payload/>