Config Files in COM+ Applications

One of the reasons that I blog is to help me keep track of the nuggets of information that I come across in my travels to various clients. I long ago gave up the idea that I could remember everything that I learned and as I get older, the volume that I remember seems to be decreasing, especially as a percentage of the knowledge that would be useful to have.  As a result, my reasons for posting are not always altruistic.  This is one such post.

The initial problem was encountered at a client last year. The situation involved trying to create a configuration for a server-style COM+ application. For the normal application, configuration settings are stored in a file named executable.exe.config.  But for server-style COM+ applications, all of then applications are run by dllhost.exe.  This means that they would use (by default) the dllhost.exe.config file, the location of which is normally in the %windir%/System32 directory. There are situations, however, where this is not acceptable.  So it becomes necessary to create individual config files for different COM+ applications.

The solution involves the application.manifest file. First, in the configuration screen for the COM+ application, set the Application Root Directory to a particular directory.  Any directory will do, but it needs to be different for each application that requires its own config file.  In the specified directory, two files need to be added.  The first is a file called application.manifest.  This file is intended to describe the dependencies that are required by a particular application.  However, the contents of the file for this particular purpose can be quite simple.  For example, the following is sufficient.

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

The second file, again placed into the Application Root Directory, is called application.config.  The contents of this file is the normal config file.  With these two files in place, the COM+ application now has the freedom to access its own configuration information through the regular channels. Flexibility lives!!

Comments

  • bruce February 24, 2004 7:11 PM

    Do you know of a way to use the AssemblyInfo.vb file of a DLL to set the default configuration of the ApplicationRootDirectory for the COM+ application.

    Ie. similiar to
    <Assembly: ApplicationActivation(ActivationOption.Server)>

  • bruce June 7, 2004 4:17 PM

    Thank you very much for this nugget of info.

    You just saved me a ton of time and I greatly appreciate it.

    have a great week!

  • bruce September 8, 2004 11:48 AM

    And once again Google solved my problem, great tip, you saved my day.

  • bruce December 8, 2004 9:00 AM

    I completely agree, this was very useful information!

  • bruce October 29, 2005 9:14 PM

    Very useful....Thanks

  • bruce December 7, 2005 1:14 AM

    The most simple application.manifest file (as you have above) is causing us SideBySide errors and our COM+ apps won't start....any ideas?

    Thanks

  • bruce May 22, 2006 6:20 AM

    Thank you so much.

  • bruce July 15, 2006 8:04 AM

    Thanks much. It worked.

  • bruce July 28, 2006 7:02 AM

    I tried this using 2005 and it does not seem to work

  • bruce October 11, 2006 1:51 PM

    I followed your advice, but I still cannot get this to work. I have put the manifest file and the application.config in the root directory after setting this directory for the component. Is this the proper name for the config file? What about security settings for the root directory? I am running the COM+ component as a server application. Please email me if you have any answers.

    Thanks.

  • bruce December 12, 2006 2:03 PM

    I have a similar problem instantiating a .NET COM (VB .NET 2003) object from an ASP page (VB script).

    Configuration and probing path problems can be worked round by creating a dllhost.exe.config file. However this is not really satisfactory.

    Any ideas for a better solution?

  • Sc April 15, 2008 11:56 AM

    This does not work for me either. I have the manifest and config file, and the app will not start. Removing the manifest allows the app to start. Why?

  • SteveC April 15, 2008 1:24 PM

    The most likely reason this works for some and not others is the service's access to the local filesystem. If the COM+ app runs as LocalSystem, it has priviledges to get at the manifest file; if it is not LocalSystem or an equivalent, the runtime tells it to read the manifest file but Win32 won't let it, so it explodes with a vague error.

    Hope that helps someone.

  • GeorgeG June 18, 2008 2:34 AM

    Sorry but this does not work for me either. The com+ app is set to use the currently logged on user. So I dont see how it wont have the right priviledges to access the files. Should the files be named excactly as 'application.manifest' and 'application.config' ??

    Any ideas will be appreciated..

  • GeorgeG June 18, 2008 2:39 AM

    In 'Activation' tab i cheched the "Run application as NT service' and it worked.. so you were right. :)

    Need to check now if there are any drawbacks running the application as a windows service.

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS