My maui app needs to read a registry key from HKLMSOFTWAREcompanyproduct to find the full path to the executeable of an other installed program.
Screenshot of regedit
It works fine when the app is deployed from visual studio, but doesn’t work if the app is pushlished, signed and manually installed (sideload).
A System.NullReferenceException is thrown when accessing the registry:
System.NullReferenceException: Object reference not set to an instance of an object.
My code for accessing the Registry item:
private async void StartSignation() {
#if WINDOWS
try {
string pathToExe = Registry.GetValue(HKEY_LOCAL_MACHINE\SOFTWARE\company\product", null, null).ToString();
} catch(Exception ex) {
// Log this exception
}
#endif
}
The code gets called from a TapGestureRecognizer:
<controls:LinkIconButton LabelText="read registry" Icon="registry.png">
<controls:LinkIconButton.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
</controls:LinkIconButton.GestureRecognizers>
</controls:LinkIconButton>
PlatformsWindowsPackage.appxmanifest contains this
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
How to access the registry at productive deployed release?