Problem reading appSettings
I placed some values in LINQPad.config file's appSettings sections like this:
In the code I was trying to do get the value but no value was returned:
var loadDate = ConfigurationManager.AppSettings["LoadDate"];
What did I do wrong?
In the code I was trying to do get the value but no value was returned:
var loadDate = ConfigurationManager.AppSettings["LoadDate"];
What did I do wrong?
Comments
I take it you've put the settings into linqpad.config (and not linqpad.app.config?)
What does the following query return?
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
C:\Users\changc\Desktop\LINQPad.config
Thanks!
My LinqPad is installed in C:\Program Files\LINQPad5
I wonder why the config would to somewhere else other than C:\Program Files\LINQPad5\LINQPad.config?
Thanks.
Try creating a new query with no references and default properties. Then AppDomain.CurrentDomain.SetupInformation.ConfigurationFile should return C:\Program Files\LINQPad5\LINQPad.config
returns
C:\Users\dennis\AppData\Local\LINQPad\empty.config
I also then added a reference to System.Configuration, and I get the same result.
As per the FAQ, I'm trying to "create a file called linqpad.config in the same folder as LINQPad.exe. Anything you put here applies to all queries (unless you override it in the dialog above). " to have a merged set of settings, but I can't get it to work.
I set up a new LinqPad exe folder - i.e XCOPY deployed. Running from there, ConfigurationFile.Dump() shows
C:\Users\dennis\AppData\Local\Temp\LINQPad5\_yhiiwvkz\tzuqwq\LINQPadQuery.dll.custom.config
I still don't get a merged AppSettings.
What should the root node of Linqpad.config be? I've tried just
and also
You can also specify a config per query by going to query properties F4 and going to the app.config tab.
The "LINQPadQuery.dll.custom.config" is indeed a merged config. It should contain everything that's in the LINQPad.config file (or whatever you've specified in query properties) plus binding redirects necessary for you query to function.
Yes.
If the F4 App.config tab is set to "Global default ...", then yes, AppDomain.CurrentDomain.SetupInformation.ConfigurationFile does return that. (If set to "Custom path" then it returns that path)
But if the tab is set to "Let me type it in", then a temporary path is returned - e.g
C:\Users\dennis\AppData\Local\Temp\LINQPad5\_nrixxzun\rguhkq\LINQPadQuery.dll.custom.config
When I was asking about "merged", it's whether or not multiple appSetting sections (from multiple config files) are merged.