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

后端 未结 3 1108
渐次进展
渐次进展 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:53

    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

提交回复
热议问题