Server Activated ServicedComponent and Config Files

Yes, it is possible to specify a per-component application config when using a ServicedComponent with activation type set to Server Application. By default all Server Applications are sharing dllhost.exe.config located in %windir%\system32.  But there are cases when you need to have different configs for different Server Apps. For instance, an important scenario is to have component A using version 1.0 of .Net Framework and component B using version 1.1.

This can be achieved by setting the Application Root Directory for that component to point to a directory where you have two files: application.manifest and application.config. The manifest can be as simple as:

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

The application.config will be your normal app config where you can put your specific settings for your component.

[Originally posted Oct 13, 2003]

Comments (15)

  1. Paul says:

    Hi Florin, this feature works only for winxp and win2k3. Do you know if exists something similar under win2k ?. Thanks.

  2. Florin Lazar says:

    Paul – Unfortunately Win2K doesn’t support per app config files because Win2K doesn’t have Application Root Directory.

  3. Dante says:

    Hi folrin, i’ve been trying this for some time and it just won’t work, i have winXP prof, do i need to install service pack 2 for this to work? thanks

  4. Florin Lazar says:

    Dante, on XP you need at least COM+ QFE Rollup #6 (QXP 6) to be able to use this feature. You have two options: 1. Contact Microsoft Support to obtain the rollup or 2. Wait for SP2 for XP to be released.

  5. Cibra says:

    Under W2k3, the files can be renamed as <ServerApplicationName>.manifest and <ServerApplicationName>.config. Unfortunately this solution doesn’t work under windows xp

  6. All out-of-process COM applications by default are executed using the %SystemRoot%System32dllhost.exe surrogate process. What this used to mean that calling System.Configuration.ConfigurationSettings.AppSettings[

  7. Kash says:

    Hi i have similar problems

    I’m developing mmc SNAP-in in vb6 using snapin designer,

    snain needs to interact with database ,

    database interaction code is written in,

    to use that .net assembly i register it for COM interoperability, And it successfully run in vb form project , And all config file settings successfdully obtained when runnin vb6 project exe.

    Now i use that same assembly in snapin by registering for COM interoperability.

    ( Snapin creates .ocx file)

    Now when i load snapin in mmc, it woun’t find any config file, even though i renamed app.config as dllhost.exe.config

    I’m using win2k

    Any type of help highly appreciated

  8. Oren says:

    Hi there do you have any idea how to overcome the problem under the W2K environment any idea will be highly appreciated THNAKS

  9. Roni Burd says:

    For win2k I copied a code fragment that was suggested of ADVANCED DOTNET list.(I’m not sure from whom, and modified 4 lines of code)

    I post the source code because so maybe it can be useful to others. Basically all you have to do is inherit for ServicedComponentEx.

    Good luck!


    public class ServicedComponentExProxyAttribute : ProxyAttribute, ICustomFactory


    private ProxyAttribute _base;

    private Type currentType;

    static AppDomain appDomain = null;

    public ServicedComponentExProxyAttribute()


    _base = (ProxyAttribute)typeof(ServicedComponent).GetCustomAttributes(typeof(ProxyAttribute),false)[0];


    public override MarshalByRefObject CreateInstance(Type serverType)


    return _base.CreateInstance(serverType);


    public override RealProxy CreateProxy(ObjRef objRef,Type serverType,object serverObject,Context serverContext)


    return _base.CreateProxy(objRef,serverType,serverObject,serverContext);


    Assembly ResolveHelper(object o, ResolveEventArgs rargs)


    if ( currentType.Assembly.FullName == rargs.Name )


    return Assembly.LoadFrom(currentType.Assembly.Location);




    return null;



    MarshalByRefObject ICustomFactory.CreateInstance(Type serverType)


    if ( AppDomain.CurrentDomain.FriendlyName == "myappdomain" )


    return ((ICustomFactory)_base).CreateInstance(serverType);




    if ( appDomain == null )


    System.AppDomainSetup appDomainSetup = new AppDomainSetup();

    appDomainSetup.ApplicationBase =

    Path.Combine(Path.GetPathRoot(serverType.Assembly.Location), Path.GetDirectoryName(serverType.Assembly.Location));

    appDomainSetup.ApplicationName = "complus";

    appDomainSetup.ConfigurationFile = serverType.Assembly.GetName().Name + ".exe.config";

    appDomain = AppDomain.CreateDomain("myappdomain",null,appDomainSetup);


    ResolveEventHandler reh = new ResolveEventHandler(this.ResolveHelper);

    currentType = serverType;

    AppDomain.CurrentDomain.AssemblyResolve += reh;

    MarshalByRefObject mbr = (MarshalByRefObject)appDomain.CreateInstanceFromAndUnwrap(serverType.Assembly.Location,serverType.FullName);

    AppDomain.CurrentDomain.AssemblyResolve -= reh;

    currentType = null;

    return mbr;





    public class ServicedComponentEx : ServicedComponent


    public ServicedComponentEx()



  10. Sam says:

    On XP/2003, application.manifest and application.config work well as long as the component is being called by a client without a transaction context.

    If you want to call the same component from a client under a new transaction context (this is easy to do by the way), then the component does not seem to be able to access the app.config file anymore.

    I have some code that illustrates my point if anybody is interested. I would appreciate any suggestions/workarounds to make this thing work.

  11. Brian Russell says:

    Or you could just call AppDomain.CurrentDomain.SetData("APP_CON- FIG_FILE", settingsFilePath);

  12. I spent far too much time on Friday trying to make log4net work in a COM+ application. Someone else had