ExeptionHandling 3 tier solution

Topics: Exception Handling Application Block
Aug 23, 2007 at 12:23 PM
Hi I have a 3 tier solution and I want to implement Enterprise Library Exception Handling Application Block 3.1.
The problem I face is that I want to handle all exceptions in one place, to test this concept I have created 3 solutions UI, Common and DB and implemented EL Exceptionhandling in Common and created a static method in Common that takes an exception and a policy as parameters and calls ExceptionPolicy.HandleException. I also added an app.config to Common with the configuration settings.
From UI I then throw an exception and in the catch section calls the static method of Common.
The problem is that EL looks for the config settings in web.config of UI instead of the app.config in Common.
I have read http://davidhayden.com/blog/dave/archive/2006/01/07/2684.aspx and http://blogs.msdn.com/tomholl/archive/2006/04/02/entlib2externalconfig.aspx
but the problem is that I don't want to specify an absolute path to my app.config in Common
and all relative paths seem to start from the caller (UI or DB)
Does anyone have way around this? or another solution to this problem.
Best regards Sven Hasselblad
Aug 28, 2007 at 2:15 PM
Hi,

I'm a bit confused about what you're trying to achieve. Common seems more a project than a solution, and don't have configuration for solutions but for applications; configuration files can be part of projects, but they will likely be updated then the application is deployed.

Even if you do have a "common" project, and you want to specify the configuration file in that project and use a configuration source to read that file (which would be defined in the config file for your application - either web.config or exe name.config depending on the kind of application), you shouldn't think about how the source artifacts are laid out in the file system but instead you need to make sure the build output is correct. In this case, correct means the file with the configuration from "common" is in the build output folder for you web app. Unless there is a very compelling reason, you don't want to use fixed paths in your config files; that makes them brittle.

Hope this helps,
Fernando