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?

Comments

  • The html is not showing up there:
    <appSettings>
    	  <add key="LoadDate" value="5/27/2013"/>
      </appSettings>
  • I tried your exact sample and ConfigurationManager.AppSettings["LoadDate"] returned 5/27/2013.

    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
  • it returns
    C:\Users\changc\Desktop\LINQPad.config
  • I know what's wrong. When I double click on the .linq file, it's not working. But if I open LINQPad first then drag the .linq file into LINQPad, it will work.
  • Perhaps you have .linq files associated in Windows with a copy of LINQPad.exe that resides in a different folder.
  • Yes that's right I have a different version on my desktop where I used to run my .linq files. When I removed that old LINQPad.exe and tried to associate the .linq again with the exe that resides in the same folder in my desktop, I found I can't associate it. Is it because LINQPad.exe is a portable program? Is there a better way to associate my .linq files with LINQPad.exe where it's not directly on my desktop? Since now I have more files need to be put in the same folder.( all the config files, lprun.exe)
  • I found I can do it. I just pin where my LINQPad.exe to the taskbar. Then I can associate .linq file from properties' association.

    Thanks!
  • @JoeAlbahari I have a similar problem but the `AppDomain.CurrentDomain.SetupInformation.ConfigurationFile` returns C:\Users\myUser\AppData\Local\Temp\LINQPad5\_orthtqce\nzlyzh\LINQPadQuery.dll.custom.config
    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.
  • That's a merged config file. LINQPad needed to apply binding redirects to your query, so it read the normal config file, added the binding redirects, and wrote the merged file to a temp location.

    Try creating a new query with no references and default properties. Then AppDomain.CurrentDomain.SetupInformation.ConfigurationFile should return C:\Program Files\LINQPad5\LINQPad.config
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!