App not working in Program Files (x86) folder

As the title suggests, when I build my app and run it from the Builds folder or in other places, it works fine. But when I run the installer I made and try to run it, trying to open a file in the app results in “An exception of class NilObjectException was not handled”. Any ideas as to why this isn’t working?

A NilObjectException means you have a bug in your code somewhere. I’d guess the cause is file access. Perhaps a FolderItem you are trying to use is not accessible in the same way when you run from Program Files.

Add code to check if things are Nil and perhaps output some logging to help you pin it down.

If you are trying to access a file held ‘next to the app’, it will not work in Program Files due to permissions.
Such a file must go into Specialfolder.applicationdata

Yes, thanks, the file is next to the app.

A easy way to see if it is permission related is Right click the app and run it as Administrator.

You can read the file probably but can’t write to it (or even open it with write permissions)

I move the file to the AppData folder and changed the code, and it works fine now. Thanks!

2 Likes

As @Paul_Lefebvre wrote earlier, even if you have found a way to access your file, your code should test against nil anyway (cleaner than getting exceptions, especially if you don’t handle them and your app quits).