Coding Blog

Jim Scott's coding blog

Getting LINQPad to read your applications App.Config settings

I have been using LINQPad for a while now and I love it. This utility allows me to write and execute immediately code that I am working out before I put it into my project. However on occassion I need to reference assemblies from my project that are getting settings from the applications App.Config such as SQL connection strings etc...

Each time I would run into this I would search and not come up with how to get my app.config settings to be honored by LINQPad and today I finally found how to do it so I thought I would write up something really quick to show others how to accomplish this.

1) Find the path that LINQPad uses for its configuration file by excuting this: AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.Dump()

This returned for me the following: C:\Program Files\LINQPad4\LINQPad.config

I was suprised this returned LINQPad.config instead of LINQPad.exe.config which is what you would typically expect since most .NET applications name the file the same as the executable.

2) Take your App.config and copy it to the location above naming the config file whatever yours returned. In my case it was LINQPad.config

3) Close LINQPad or the TAB that you have opened to execute your assembly and reopen to get LINQPad to read the configuration file.

Now execute your code and you should see that LINQPad is now pulling in your settings as needed.

 

Posted: Jun 01 2012, 14:06 by jscott | Comments (3) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:

Comments (3) -

Colin Kraebel United States said:

Thank you. This post is very helpful!

# January 10 2013, 13:30

Matthew Cooper United States said:

Thank you soo much!!!!

# February 04 2013, 13:42

Joe Albahari Australia said:

Spot on: LINQPad.config is for your queries.

LINQPad.app.config is for the LINQPad host UI, whereas
LINQPad.config is for your queries.

# April 11 2013, 07:15

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading