What if your managed code is hosted inside the COM+ component and you still need to access the settings similar to what you have in WinForms (app.config) or ASP.NET (web.config ) application?

If your component is configured as a Library Application, then it will use the settings from the hosting application since it is runnig in-proc. If the component is configured as a Server Application, the choices are presented below:

  1. Create/update dllhost.exe.config file (Very bad idea since it will affect all COM+ applications on the machine)
  2. Provide the initialization constructor (Too much effort)
  3. Create custom configuration scheme (Too much effort)
  4. Use the Application Root Directory and manifest file (The easiest way with minimum impact

To go with the last approach you shall need to configure the Application Root Directory setting (avaialble for COM+ 1.5 - Windows XP and Windows Server 2003) and put two files application.manifest and application.config into this directory.

Application.Manifest must contain the following:

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

Application.Config is the standard .NET configuration file.