Recently, I added a setup project to my application. In the setup project, I added a registry value that would start my application at windows startup to the HKLM\Software\Microsoft\Windows\CurrentVersion\Run key. When the application runs from this location, it crashes with a System.NullReference exception (it can't find my app.config file, which gets read in a method when the app loads up). I can run the application perfectly fine from the start menu, or from the installed folder. How can I get my application to run at Startup?
+1
A:
I believe that will be running with the system folder as the working folder. Either putting the config file in the system folder or ensuring the working folder is set should fix the problem.
Tom Clarkson
2009-05-07 13:32:23
How would I set the working folder in the Registry Key? Would I need to do that in the Setup project?
sunmorgus
2009-05-07 13:37:01
I got it...I check Environment.CurrentDirectory on the app's startup, and if it contains system32, then I set it to the Application.StartupPath. Thanks!
sunmorgus
2009-05-07 13:56:04
Just as a note...I also had to check and see if the Environment.CurrentDirectory contained syswow64 for a 64bit os...
sunmorgus
2009-05-08 17:53:49