none
Issue with System.Configuration.ConfigurationManager.GetSection(String sectionName) in container RRS feed

  • Question

  • Hi. I've been trying to convert a .net console app to be run as an entry point in a windows docker container (on a windows host).

    It is not a .net core app.

    I keep getting exceptions thrown when trying to access Properties.Settings, and other config files.

    It appears to be attempting to access a user config file that doesn't exist (entrypoint is running as ContainerAdministrator).

    can anyone tell me what I need to set in this image to get this to work?

    according to the documentation:

    For client applications, this method retrieves a configuration file obtained by merging the application configuration file, the local user configuration file, and the roaming configuration file.

    exception:

    System.Runtime.InteropServices.COMException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
       at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
       at System.Security.Policy.PEFileEvidenceFactory.GenerateLocationEvidence()
       at System.Security.Policy.PEFileEvidenceFactory.GenerateEvidence(Type evidenceType)
       at System.Security.Policy.AssemblyEvidenceFactory.GenerateEvidence(Type evidenceType)
       at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
       at System.Security.Policy.Evidence.GetHostEvidence(Type type, Boolean markDelayEvaluatedEvidenceUsed)
       at System.Security.Policy.AppDomainEvidenceFactory.GenerateEvidence(Type evidenceType)
       at System.Security.Policy.Evidence.GetHostEvidenceNoLock(Type type)
       at System.Security.Policy.Evidence.RawEvidenceEnumerator.MoveNext()
       at System.Security.Policy.Evidence.EvidenceEnumerator.MoveNext()
       at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
       at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
       at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
       at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
       at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
       at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
       at System.Configuration.ConfigurationManager.GetSection(String sectionName)

    Docker file:

    FROM microsoft/aspnet:4.7.2-windowsservercore-1803
    SHELL [“powershell”, “-Command”, “$ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’;”]
    RUN powershell -NoProfile -Command New-Item -ItemType directory -Path C:\logs
    RUN powershell -NoProfile -Command New-Item -ItemType directory -Path C:\MyService
    
    WORKDIR /MyService
    COPY ./bin/Release/ /MyService
    EntryPoint ./MyService.exe “CONSOLE”
    thank you


    • Edited by Snowfire Tuesday, June 26, 2018 1:04 PM
    Tuesday, June 26, 2018 1:01 PM

All replies