Com+ App components uses assembly

Topics: Building and extending application blocks, Exception Handling Application Block
Aug 9, 2007 at 1:18 PM
I am about to implement My com+ Application to use my .NET assembly ExceptionManager.dll
My ExceptionManager uses EnterpriceLibrary 3.1 Exception Handling and Loggin Application Block.
It needs the reference to the Exception.config which is an EnterpriceLibrary config file.

The ExceptionManager does the following ...

public static string ConfigFile = Path.Combine(Assembly.GetCallingAssembly().Location.Substring(0, Assembly.GetCallingAssembly().Location.LastIndexOf('\\')), "Exception.Config");
public static FileConfigurationSource StaticConfigurationSource = new FileConfigurationSource(ConfigFile);
public static ExceptionPolicyFactory ConfiguredPolicyFactory = new ExceptionPolicyFactory(StaticConfigurationSource);

private static bool HandleException(Exception exceptionToHandle, string policyName)
ExceptionPolicyImpl policy = GetExceptionPolicy(exceptionToHandle, policyName, ConfiguredPolicyFactory);
return policy.HandleException(exceptionToHandle);

On the Client this works perfectly ...

On the Server, when implementing com ++ components using ExceptionManager it is unable to find the Exception.Config
I put ExceptionManager.dll in the GAC but the reference to the Exception.config will not work ...

A solution to the problem could be to put the path for the config file in the registry or set the AppSource on the com++ components( not supported by windows 2000 server ?)

Are there any other possibilities?


Aug 9, 2007 at 7:09 PM

Does Path.Combine(Assembly.GetCallingAssembly().Location.Substring(0, Assembly.GetCallingAssembly().Location.LastIndexOf('\\')), "Exception.Config"); resolve to the appropriate path in your server?
Does the user running your application have access to the location where the file resides?

Aug 10, 2007 at 6:03 AM

The answer to your question is: no, the code does not resolve the appropriate path on the server

To be more specific,
I have:

App dir\ where the Com+ app recides

GAC\ /* Global assembly cache where I put most of my assemblys*/

windows\system32\ where "dllhost.dll" recides

The Com+ app uses the dllhost.dll ( in windows\system32 ) which in turn calls the .Net assemblys in GAC.
The path I get on the server will then be windows\system32

I do not want to put my Exception.config file there.


Aug 10, 2007 at 2:58 PM

Unfortunately you will have to rely on some external, well known source of information like the registry if you're using Windows 2000, as the Application Root Directory is supported since COM+ v1.5.

If you don't want to use the registry you could use a custom app setting in your dllhost.dll.config file with the path for your Exception.config file, and default to your current behavior if the setting is not found.