Multiple modules with an app.config each

Topics: Exception Handling Application Block, General discussion
May 6, 2009 at 11:24 AM
I'm developing an application which consinst of several modules (libraries) which can be combined as needed. Example: Customer A wants modules B,C,D and Customer B only needs modules B and D.
I'm using the exceptionhandling block in all modules, but some policies are only needed in one module and so only defined in that modules app.config. How can i make these policies of several such modules known to my main application?

I could ofcourse define everything in my main app.config, but that is something i'm trying to avoid, to make it easier to alter the handling blocks for each module.

Kind regards
May 6, 2009 at 11:35 AM
You could create an instance of ExceptionPolicyFactory passing an instance of FileConfigurationSource which points to the config file which has the exceptionpolicy. For example:

IConfigurationSource configSource = new FileConfigurationSource("path_to_app.config");
ExceptionPolicyFactory factory = new ExceptionPolicyFactory(configSource);
ExceptionPolicyImpl policyImpl = factory.Create();


Hope this helps.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.



May 6, 2009 at 11:55 AM
Hi Sarah,

thanks for the fast answer. Your tip did it except for a little change:
I had to use
ExceptionPolicyImpl policyImpl = factory.Create("Policy_Name");
I forgot to add: I'm using Entlib 3.1. 
I'll try to create several factories/policies for each module when loaded an then try this approach.

Thank you very much for your help.



May 6, 2009 at 1:33 PM
Yeah, I was just typing that code just to make sure I got the name of the classes right, sorry 'bout that :)

Glad to be of help.

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.