Config files are easy to do in .net 2.0 and up. You add a little file to your project through the properties dialog and poof, you’ve got a strongly typed settings file stored in an easy to edit XML file.

Well, I deployed a dll with a config file (conveniently named dllfilename.dll.config) to our business server and despite all of the Settings.Default.Reload() statements that I put in, the darn thing would never update with the values that I put in there.

After I created a test project and fooled around with it a while, I came to understand that if you have an EXE calling a dll, the config file that your dll is going to look for will be named exefilename.exe.dll!

Sure would have been nice for microsoft to make that more prominent in their documentation!

So, after a few dozen failed attempts at asking Google for the answer, I finally figured out the correct wording to find what I needed…

…and of course it’s an ill-documented “magic word” to get it done…

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", @"C:\somepath\someconfigfile");

So there it is, maybe next time someone wants to specify a config file for their dll, or override or replace or specify their own config file for an assembly, all of the words that I just typed out will help them find it….

Next Page »