I have this simple piece of code, adding my application to run when windows start. Works fine.
RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
rk.SetValue("my_app", Application.ExecutablePath);
Then I package it with a Windows Application Packaging Project, connect it to windows store, choose "Create App Packages.." and get the resulting .appxbundle. Fine so far. I install it locally. (also installing the generated certificate (.cer) so I can install it at all.)
Once I start the installed app and click a button running the code above, nothing changes in the registry! It does not crash, I have a try..catch around the code. It just silently ignore it.
Running it from visual studio works fine, the registry gets updated.
Actually, all I want is the app to start when windows start, I am not particularly interested in how to achieve that, so any ideas are welcome!
Edit: I forgot to say the most important stuff: It is a Windows Desktop, Windows Forms App. It is not a UWP app, but a window inheriting an ordinary System.Windows.Forms.Form, compiled with x86.
Xavier mentions the StartupTask extension, it's a nuget package but it seems to be used when you have a UWP app.