Dynamic connection configuration on Serviced components RRS feed

  • Question

  • Hi,
    We're architecturing a model which will be used by our company developers, when writing assemblies and serviced components.

    Now we have to define how our components will read data access parameters like username\password\dbServer, cause we don't want these parameters hardcoded inside components source code.
    As we have various environment on ours applications alike: delelopment, test, production
    the components must be able to work on any database, so we have to read the working database dynamically from component code, or pass these data as parameters.

    I'm thinking about developing a service providing an administration console concentrating all the configuration settings per application, or per component when necessary. This service would have a proxy from which the components could query configuration data.
    To provide settings per application or per component each method would receive a optional parameter indicating an application "context" used to query configuration information.

    Is this a good approach ?
    Do I can obtain the same using the .net 2.0 configuration application block + system.Configuration ?

    Any comment or guidance would be very appreciated.

    Wednesday, June 14, 2006 1:03 PM

All replies

  • Because serviced compontents run in the COM+ context, using a standard app.config won't work.

    To get a configuration file loaded you must do several things to tell the .NET Framework where to look for it.

    First you must configure your COM+ Component package to have an Application Root Directory. You do this by right clicking your COM+ package in Component Services, selecting properties, clicking the Activation tab, and filling in the Application Root Directory text box with the directory in which your component's DLLs reside.

    Second you must create an XML file called the application manifest. Name the file "application.manifest" and place the following XML in it:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"></assembly>

    Lastly, you need to create your app.config. Name it "application.config" and fill it with the normal application settings.

    You could store all your application settings in here. If you need the ability to more easily manage staging vs production values you may have to resort to a database-based configuration scheme. In this case, you can at least store your database connection string in your application.config.
    Tuesday, June 20, 2006 3:48 AM

    Thanks for the the information, it'll be very useful soon.

    For now I'll develop the database based configuration and a service.

    Thanks again.

    Tuesday, June 20, 2006 1:24 PM