I have something curious that I am hoping a .Net expert can help me with.
I have a custom configuration section and to get hold of it I do this:
va
ConfigurationManager.GetSection(String):
retrieves a configuration file obtained by merging the application configuration file, the local user configuration file, and the roaming configuration file.
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel):
The userLevel parameter determines the location of the configuration file being opened by indicating whether it has no user level (the configuration file is in the same directory as the application)
So, they're opening different files. Take a look using ProcessMonitor to find out which files are being accessed and why an exception occurs and on which file.
I had this same behavior when the assembly was "blocked" (under the file properties tab). The files were emailed via a zip to the admin. When he saved off the attachment, the block bit was added...just like when you download a file from the internet. After we clear the block, it worked fine.
I know this is an old thread, but I ran into this problem recently when working with a client and thought I'd post another suggestion. In my case the issue was using a non-static ConfigurationManager method, which can cause a SecurityException under certain specific conditions (app targeting .NET Framework 4 and installed on a network drive, and in this case also Windows Update being disabled). Here is more information on the problem and a hotfix from Microsoft:
https://support.microsoft.com/en-us/help/2580188/fix-system.security.securityexception-occurs-when-a-.net-framework-4-based-application-that-calls-a-static-method-in-the-system.configuration.configurationmanager-class-runs-on-a-network-share