WiX Burn Managed Bootstrapper无法加载 - 错误0x80040150

时间:2013-12-13 23:52:21

标签: c# wix installation bootstrapper burn

截至昨天,我的托管引导程序无法在某些计算机上运行,​​并出现以下错误:

[07F4:13CC][2013-12-12T12:20:31]e000: Error 0x80040150: Failed to create the managed bootstrapper application. 
[07F4:13CC][2013-12-12T12:20:31]e000: Error 0x80040150: Failed to create UX.
[07F4:13CC][2013-12-12T12:20:31]e000: Error 0x80040150: Failed to load UX.
[07F4:13CC][2013-12-12T12:20:31]e000: Error 0x80040150: Failed while running
... 
...
[07F4:13CC][2013-12-12T12:20:31]e000: Error 0x80040150: Failed to run per-user mode.

显然,0x80040150(2147746128)是:REGDB_E_READREGDB:无法从注册表中读取密钥

在事件日志中,我可以看到

Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards. No user action is required.  

 DETAIL - 
 7 user registry handles leaked from \Registry\User\S-1-5-21-4128267814-1525589554-1895505527-1113_Classes:
Process 4332 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<file>.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES
Process 4332 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<file>.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES
Process 6180 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<folder>\BurnBasedSetupKit.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES
Process 6180 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<folder>\BurnBasedSetupKit.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES
Process 3408 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<folder>\BurnBasedSetupKit.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES
Process 3408 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<folder>\BurnBasedSetupKit.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES
Process 4332 (\Device\HarddiskVolume4\Users\<username>\AppData\Roaming\<companyname>\<product>\<file>.exe) has opened key \REGISTRY\USER\S-1-5-21-4128267814-1525589554-1895505527-1113_CLASSES

可能有必要提一下,使用c#代码的服务调用BurnBasedSetupKit.exe:

Process proc = new Process();
proc.StartInfo.FileName = "BurnBasedSetupKit.exe";
proc.StartInfo.Arguments = string.Format("-s -l {0}", logFileName);
proc.StartInfo.Verb = "runas";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.ErrorDialog = false;
proc.StartInfo.RedirectStandardOutput = true;    
proc.Start();
proc.WaitForExit();
if (proc.ExitCode != 0)
{
    throw new Exception(string.Format("Setup execution process exited with non-zero ExitCode: {0}", proc.ExitCode.ToString()));
}    

该服务在本地管理员组中的用户下运行。当机器运行但没有用户登录时,服务可以很好地调用BurnBasedSetupKit.exe。[注意:当以交互方式调用BurnBasedSetupKit.exe工具包时,一切正常。]

我尝试升级到最新的稳定版WiX工具集,但仍然会出现同样的问题。这似乎只在某些机器上出现。我的自定义托管引导程序代码库没有任何变化,它几个月来一直运行良好。

我已确认与其他遇到类似错误的人(herehereherehere)没有相同的问题。

如果有人可以解释一下,我将不胜感激。

更新

经过一些试验和错误后,当启动安装工具包的服务在调用安装工具包之前重新启动,从不同的进程空间启动时,会出现此问题。然而,这不是确定性的。

1 个答案:

答案 0 :(得分:0)

我已将其缩小为两个组合,不一定相关:(a)服务将孤立句柄留给用户注册表配置单元,以及(b)Windows用户配置文件服务主动杀死任何用户注册表配置单元处理服务已经开放供引导程序使用。

重启服务似乎可以缓解这个问题,我相信在调用引导程序之前清除所有孤立的注册表句柄。另一种解决方案可能是通过P / Invoke使用本机C ++调用创建进程,并让子进程继承句柄(.NET调用似乎不允许用户显式指定句柄的继承)。这应该可以防止用户配置文件服务将注册表句柄检测为孤立,并允许引导程序根据需要使用用户配置文件的资源。此外,我还在调用安装工具包之前加载了服务标识的用户配置文件。这些步骤的组合解决了这个问题。