--> Enterprise Services and app.config - Impersonation Failure

Enterprise Services and app.config

All COM+ applications (.NET Serviced Components) with it's activation type set to Server Application are by default executed using the %SystemRoot%\System32\dllhost.exe surrogate process. What this used to mean that calling System.Configuration.ConfigurationSettings.AppSettings["key"] would try and locate the value from the applications configuration file which in a ServicedComponent environment would mean trying to load the value from the element in the dllhost.exe.config in the System32 folder.

This is not ideal as storing info in that file would mean that your settings is shared across all COM+ Server applications.

With COM+ 1.5 (Windows Server 2003 or Windows XP SP2) you can now have application specific application configuration files by using a specified application root folder. You can set this through the Component Services MMC snapin by right-clicking on your COM+ application and navigating to the Activation Tab, at the bottom there's a space where you can specify a new application root folder.

To get this working you also have to create two files in this location, application.manifest and application.config files. That needs to be the exact names on XP, no need to name the file as yourserverapplication.dll.config etc. On Windows Server 2003 you can rename them .manifest and .config.

application.manifest is very straight-forward :

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

application.config follows the normal app.config type syntax :

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="connString" value="connectionString" />

</appSettings>

</configuration>

One thing to keep in mind especially during development is that you have to respecify the application root after every compile.

More information :

[1] - Clemens Vasters [2] - Florin Lazar

 

Filed under:

Comments

No Comments