Why does using ConfigurationManager.GetSection cause “SecurityException: Request failed” but ConfigurationManager.OpenExeConfiguration does not?

后端 未结 3 1138
渐次进展
渐次进展 2021-01-11 22:24

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         


        
3条回答
  •  余生分开走
    2021-01-11 22:43

    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.

提交回复
热议问题