Can a component designer access and modify the app.config or web.config file of a project at design time? More specifically, is there some hosting service exposed by VS to do this 'the proper way' ? I know I can locate the .config file myself, open it and have my way with it as I please, but I want this to go through the VS sanctioned way, primarily because of source control integration concerns.
views:
284answers:
3component designer?¿
do you mean programaticly? http://www.beansoftware.com/ASP.NET-Tutorials/Modify-Web.Config-Run-Time.aspx
VS can and will edit you web/app config for all sorts of reasons. Also, there are certain situations where VS tools will give you a GUI for sections of the file (Which im guessing is what you are after). But for the most part the "the proper way" as you say is to hand edit it.
It could also be likely that if your project is big enough you'll have CI concerns and roll outs to several servers, which would mean scripting the generation of sections of your config files.
One final thing that's worth saying is that you shouldn't be looking for an MS blessed approach to anything, you should take your needs and come up with the most pragmatic approach with all the facts at hand.
You can hook up an IEventBindingService
(I linked to the .NET 2.0 version, there are 1.1, 3.0, and 3.5 versions too)
Excerpt from the page:
The event binding service provides a way to link an event handler with a component event from designer code.
You can put your custom app.config manipulating code into the event handler that you expose.