views:

29

answers:

2

First I create a setup from a project, and I install it.
When the program reads and writes from app.config, I get an UnauthorizedAccessException.

This works perfect in visual studio, but with creating a setup and installing it, it always crashes at this point. Someone who knows how to solve this?

Thanks

+1  A: 

youll have to provide some context as to how your running it. Are you logged in as administrator? What version of windows? where is it running from? Does the error occur when reading or writing or both?

mfalto
Not logged in as administrator, windows 7, error occurs when doing this:ConfigSettings.RemoveSetting("RecentFileName" + i);
rubentjeuh
I've tried running in administrator, and now it works. Is this possible to implement in the setup that this automaticly runs as adminstrator?
rubentjeuh
No, you can't, but you can check if the user executing the setup program is an administrator, and then tell them they need to be one and abort the install if they aren't.
Mike Atlas
see: http://omegacoder.com/?p=82
Mike Atlas
+1  A: 

This sounds like a permissions issue. Check the permissions of the app.config file in the install folder compared to the user running it. Likely the permissions of the installed location are more restrictive than the run folder that Visual Studio uses. You can control the permissions of the installation folder and the files that are installed. Exactly how this is done depends on which installer you are using.

Bill W