I'm running my c# assembly form an Azure Runtime powershell, thus reading the assembly directly. The only problem with this is that it can't find the default app.config file.
To solve this issue, I was thinking to load the configuration directly into memory by giving the path to my config file. Is this possible, and how should I do this?
My goal is to read another file than app.config, for example mycustom.config into the configuration manager.
Solution: https://stackoverflow.com/a/6151688/1408786
Edit: this also works for me, saves me hardcoded config file locations in the source code.
[System.AppDomain]::CurrentDomain.SetData("APP_CONFIG_FILE", $configPath)
[Configuration.ConfigurationManager].GetField("s_initState", "NonPublic, Static").SetValue($null, 0)
[Configuration.ConfigurationManager].GetField("s_configSystem", "NonPublic, Static").SetValue($null, $null)
([Configuration.ConfigurationManager].Assembly.GetTypes() | where {$_.FullName -eq "System.Configuration.ClientConfigPaths"})[0].GetField("s_current", "NonPublic, Static").SetValue($null, $null)
[System.Configuration.ConfigurationManager]::AppSettings
[System.Configuration.ConfigurationManager]::ConnectionStrings