How do I read Configuration Files from Class Libraries using EL

Topics: Exception Handling Application Block, General discussion, Logging Application Block
Jun 25, 2007 at 1:16 PM
Hi,

I am intending to make use of the Exception Handling Application Block and the Logging & Instrumentation Application Block in EL3.1 for my Exception Handling in the Business Tier & Data Access Tier of the Application.

However, I have some queries as the classes in the Business Tier & Data Access Tier resides in class libraries and thus do not have a host application.
1. How can I read the configuration information for EL without the host application configuration file in this case (no app.config)?
2. Must I have a host application in order to use the Enterprise Library Application Blocks?
3. If I have a presentation tier but the application resides in a different solution from the class libraries solution, can I configure the EL for use in my Business Tier & Data Access Tier? How can I achieve that?

I really appreciate any help that you can offer. Thanks.
Jun 26, 2007 at 2:42 PM
I'm facing the very same problem right now. I have several class libraries which implement controls that need the VAB configured independently.

I found the property "Configuration Sources" but it seems I can only add one configuration.

Isnt it possible to configure each dll on its own and then merge these files automaticly in the build events?

Thanks for any help!
Jun 26, 2007 at 3:29 PM
Hi,

Here are some answers to your questions.
1. You can use the FileConfigurationSource and supply the path of the configuration file. Note however that not all the functionality will be available if you create the configuration source manually. In your case, you won't be able to use the static ExceptionPolicy facade and you will have to retrieve the raw policies through an instance of class ExceptionPolicyFactory created with your FileConfigurationSource.
2. You can use the blocks in a web application ir that is what you mean; if not, please clarify.
3. The runtime behavior will not be affected by the organization of the source code. I don't know about your app's architecture, but there will be some kind of context where your business logic will reside, and the blocks will use the configuration available for that context unless you manually handle the source of configuration. You'll need to make sure the right configuration information is available when you deploy your application.

Hope this helps,
Fernando


cschong wrote:
Hi,

I am intending to make use of the Exception Handling Application Block and the Logging & Instrumentation Application Block in EL3.1 for my Exception Handling in the Business Tier & Data Access Tier of the Application.

However, I have some queries as the classes in the Business Tier & Data Access Tier resides in class libraries and thus do not have a host application.
1. How can I read the configuration information for EL without the host application configuration file in this case (no app.config)?
2. Must I have a host application in order to use the Enterprise Library Application Blocks?
3. If I have a presentation tier but the application resides in a different solution from the class libraries solution, can I configure the EL for use in my Business Tier & Data Access Tier? How can I achieve that?

I really appreciate any help that you can offer. Thanks.


Jun 26, 2007 at 3:34 PM
Hi,

I'm not sure your facing the exact same problem, as yours seems to be more about merging configuration for the same block from different partial files if I understood correctly.

You should be able to add more than one configuration source, but unless you explicitly specify which of these sources is the default you'll need to specify the name of the configuration source you want to use on the VAB APIs (the methods that require configuration on the Validation facade will let you specify a configuration source name.
Otherwise, you can certainly add some custom post build behavior to merge the configuration files form the different dlls, although you'd need to implement it.

Hope this helps,
Fernando


testalino wrote:
I'm facing the very same problem right now. I have several class libraries which implement controls that need the VAB configured independently.

I found the property "Configuration Sources" but it seems I can only add one configuration.

Isnt it possible to configure each dll on its own and then merge these files automaticly in the build events?

Thanks for any help!

Jun 27, 2007 at 12:14 PM
Hey,

sure I could merge them manually by launching a self-written tool. But isnt it a common scenario to have several dlls in a project and the dlls rely on an individual configuration, for example validation rules that apply to this dll only.
Another example applies to control developers: How would you tell your customers which exception policies they have to configure (if they don't configure it properly, the dll can't be used)? Seems to me like a dll-configuration mechanism is needed.

Regards, Andreas

Jan 10, 2008 at 1:04 PM
Hi,
I would like to raise up this topic if everyone doesn't mind.

I find Microsoft Enterprise Library really powerful and well designed tool for developers but I still cannot understand how to solve some issues mentioned in this topic.

Let's say I am developing some component library and would like to use Exception Handling Application Block. According to Exception Handling Application Block guideline I need to define exceptions policies in application configuration file. How would I do it if I have no clue how application config file is going to look like for applications where my library is going to be used? I can define these policies in assembly config file but they are just ignored when it comes to run-time. What should I do in this situation except modifying source code for EntLib to load configuration from different source other than application config?

Best regards,
Eugene