The Enterprise Library Configuration tool is very cool. If you haven't had a chance to play with it then you should join the workspace (
GotDotNet), download the Library, and check it out.
There will be 10 web casts this month on all of the code blocks. Check them out on
http://www.microsoft.com/resources/practices/events.mspx.
Today the webcast covered the configuration application block. As the webcast was going on the presenters said that you could launch the configuration editing tool from VS.NET to edit your files. This is true with one caveat, the file you click on is not loaded. (It was mentioned that the Whidbey version may/will be built into VS.NET) I decided to look into this slight oversite and fix it for the EntLib community.
It turned out to be a simple, yet hard fix. The simple part was modifying the
public static void Main() line to accept command line arguments. The hard part was working through the Microsoft.Practices.EnterpriseLibrary.Confguration.Design classes to see how they were actually loading the XML file into the UI. It was hard to do because a lot of the classes are marked internal. One thing I saw in the class I was debugging was that it opened a dialog box instead of letting the calling app pass in a file location. This struck me as odd because the class was in a Class Library project. Should this project and more specifically the OpenApplicationConfigurationCommand class always open an OpenFileDialog box? I would have prefered to be able to pass in the file location and if it was invalid then this dialog could have been opened.
My goal was to not change any code in that namespace because it was a DLL. I do not know the implications of changing its code, so I told myself that I would only change the tool (EntLibConfig.exe) code; and I succeeded. I was able to modify the app.cs file to accept a file command line argument and load that into the UI with a new class that I inherited from ConfigurationNodeCommand. With one new VS.NET file to tool association you can now load the tool with a config file already loaded.
Please download and either run the exe or build the new code into your project. The instructions for the VS.NET integration are in the app.cs file.