我无法从托管的引导程序(.NET 4.5.2)和自定义操作(尝试.NET 2.0和4.0)读取此密钥。
IndexSet(unsignedInt: -1) //Negative integer '-1' overflows when stored into unsigned type 'UInt'
我尝试使用cmd作为管理员运行bootstrapper和msi。我的测试环境是Windows 7 64位。我正在使用Wix 3.11
我制作了一个测试命令行应用程序,它能够访问此密钥。
我在引导程序和自定义操作中使用的测试代码:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages
测试输出
static RegistryKey GetHKLMKey(string registryPath) {
var hklm64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
var registryKey64 = hklm64.OpenSubKey(registryPath);
if ((registryKey64?.GetValueNames().Any()).GetValueOrDefault()) {
return registryKey64;
}
var hklm32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
return hklm32.OpenSubKey(registryPath);
}
}
...
var path = @"SOFTWARE";
foreach (var segment in @"Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages".Split('\\')) {
path += "\\"+segment;
var j = GetHKLMKey(path);
Log(path + ": " + j);
var k = Registry.LocalMachine.OpenSubKey(path);
Log(path + ": " + k);
if (k == null) return true;
}
答案 0 :(得分:2)
调试托管代码自定义操作 :不清楚是什么问题?读取不能作为自定义操作?尝试显示来自自定义操作的消息框,然后将调试器附加到运行托管代码的 rundll32.exe
进程。然后,您可以使用Visual Studio以常规的“调试方式”单步执行代码。这是来自Advanced Installer的精彩视频,向您展示了如何执行此操作:Debug C# Custom Actions。
注册表阅读 :具有调试能力后,应该有可能找出引起问题的原因。
ignore exit code
”?只有一些想法浮现在脑海。请让我们知道它是什么。