Results 1 to 3 of 3

Thread: Exception Handling Application Block using Enterprise Library 4.0

  1. #1
    Join Date
    May 2008
    Posts
    13

    Exception Handling Application Block using Enterprise Library 4.0

    Hi,
    I am trying to use Exception Handling Application Block with EL v 4.0.
    I wanted to replace an exception.
    I created the project with needed references
    1. Enterprise Library Exception Handling Application Block v 4.0
    2. Enterprise Library Shared v 4.0
    3. Microsoft.Practices.ObjectBuilder v 1.0.51206.0

    Used the Configuration Manager to create the app.config file. I then added simple code in my application that uses the ExceptionPolicy.HandleException of EL. I get the error below and I can't figure out what is wrong.

    Code:
    Dim i, j, k As Decimal
    Dim booRethrow As Boolean
    
    Try
    i = 1
    j = 0
    k = i / j
    
    Catch ex As Exception
    Try
    
    
    booRethrow = ExceptionPolicy.HandleException(ex, "Replace
    Policy")
    If booRethrow Then Throw
    
    txtMessage.Text = ex.ToString
    
    
    Catch ex2 As Exception
    txtMessage.Text = ex2.ToString
    End Try
    End Try
    End Sub
    Error Message -

    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingException:
    The current build operation (build key Build
    Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl,
    Replace Policy]) failed: The type
    'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException,
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please
    verify the spelling is correct or that the full type name is provided.
    (Strategy type
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy,
    index 2) ---> Microsoft.Practices.ObjectBuilder2.BuildFailedException: The
    current build operation (build key Build
    Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl,
    Replace Policy]) failed: The type
    'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException,
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please
    verify the spelling is correct or that the full type name is provided.
    (Strategy type
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy,
    index 2) ---> System.ArgumentException: The type
    'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractWrapperException,
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please
    verify the spelling is correct or that the full type name is provided.
    at
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.Conver tFrom(ITypeDescriptorContext
    context, CultureInfo culture, Object value)
    at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerData.get_Replace ExceptionType()
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerAssembler.Assemb le(IBuilderContext
    context, ExceptionHandlerData objectConfiguration, IConfigurationSource
    configurationSource, ConfigurationReflectionCache reflectionCache)
    at
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory `2.Create(IBuilderContext
    context, TConfiguration objectConfiguration, IConfigurationSource
    configurationSource, ConfigurationReflectionCache reflectionCache)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntryCustomFactory.Create(IBu ilderContext
    context, ExceptionTypeData objectConfiguration, IConfigurationSource
    configurationSource, ConfigurationReflectionCache reflectionCache)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IB uilderContext
    context, String name, IConfigurationSource configurationSource,
    ConfigurationReflectionCache reflectionCache)
    at
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.Pr eBuildUp(IBuilderContext context)
    at
    Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
    --- End of inner exception stack trace ---
    at
    Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
    at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator
    locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain
    strategies, Object buildKey, Object existing)
    at
    Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator
    locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain
    strategies, Object buildKey, Object existing)
    at
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.Bu ildUp[T](IReadWriteLocator
    locator, ILifetimeContainer lifetimeContainer, String id,
    IConfigurationSource configurationSource)
    at
    Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase` 1.Create(String name)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception
    exception, String policyName, ExceptionPolicyFactory factory)
    --- End of inner exception stack trace ---
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception
    exception, String policyName, ExceptionPolicyFactory factory)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception
    exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory)
    at
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
    at EHAB4v.Form1.cmdReplace_Click(Object sender, EventArgs e) in
    C:\Documents and Settings\David Woodhouse\My Documents\Visual Studio
    2008\Projects\EHAB4v\EHAB4v\Form1.vb:line 21

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Exception Handling Application Block using Enterprise Library 4.0

    I think reading the error message will help you find the problem.
    Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=4.0.0.0

    This is where the problem is.
    There is problem in assembly with the name with types associated with your app.config file. Typically with the exception handling block in Ent Lib people reference the correct assemblys in order to implement it in their applications but forget to deploy the other assemblies that it needs with it.

    Hope this helps you!

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Exception Handling Application Block using Enterprise Library 4.0

    A new screencast showing off the use of the Enterprise Library 4.0 Logging Application Block using the EnterpriseLibraryCoreExtension and LoggingBlockExtension that provide Unity IoC Integration. It shows one how to register the Logging Application Block LogWriter Class and how Unity injects the LogWriter Class into your own custom classes.

    http://www.pnpguidance.net/Screencas...creencast.aspx

    Hope this helps!

Similar Threads

  1. Exception Handling in .Net
    By Bruno007 in forum Software Development
    Replies: 5
    Last Post: 25-12-2010, 01:30 AM
  2. Exception Handling in Singleton
    By Bottlenecked in forum Software Development
    Replies: 6
    Last Post: 20-09-2010, 09:14 PM
  3. Exception handling in PL/SQL
    By Ameeryan in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 11:04 PM
  4. Exception handling in EJB
    By KennedII in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 04:40 AM
  5. Exception Handling in Csharp
    By Jesus2 in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 11:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,388,699.46074 seconds with 16 queries