WCF Enterprise Library Exception handling Error

Topics: Development Team Discussion, User Discussion
Nov 28, 2008 at 9:43 AM

In My project i am using 4 layers. so i created 4 layers and four polices in enterprise library 4.0.(Presentation,service(WCF),business, Data)

All the policy having posthandle action as "Notifyrethrow". While calling the service layer from the aspx page i got the following error.

"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Service Layer Policy]) failed: Object reference not set to an instance of an object. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2) "

After googling i found some people told check the enterpriselibrary.wcf namespace in bin directory. I have checked that and it is available.But still not able solve the issue

The Sample code implemented in Service layer
============================================
catch (Exception ex)
        {
            bool rethrow = ExceptionPolicy.HandleException(ex, "Service Layer Policy");
            if (rethrow)
            {
                ServiceFault Fault = new ServiceFault();
                Fault.MessageText = "Check user Login : " + ex.Message.ToString();             
                throw;
         
               
            }
}

other layers i used the following code it is working fine. but in service layer it is throw the exception

 

 

catch (Exception ex)

 

{

 

bool rethrow = ExceptionPolicy.HandleException(ex, "Business Layer Policy");

 

 

if (rethrow)

 

 

throw;

 

 

}

 

If anybody will give the solution for this it would be great help to me.

one more thing i am not able debug through the service layer.
I have enable the option debug = true in web.config files(Both - Service,main project)

Thanks in Advance.

Feb 8, 2010 at 2:50 AM

Make sure you declare the following:

using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;

using Microsoft.Practices.EnterpriseLibrary.Logging;