Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-02-2009
Member
 
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
Reply With Quote
  #2  
Old 07-02-2009
Member
 
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!
Reply With Quote
  #3  
Old 07-02-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Exception Handling Application Block using Enterprise Library 4.0"
Thread Thread Starter Forum Replies Last Post
Exception Handling in .Net Bruno007 Software Development 5 25-12-2010 01:30 AM
Exception Handling in Singleton Bottlenecked Software Development 6 20-09-2010 09:14 PM
Exception handling in PL/SQL Ameeryan Software Development 5 25-02-2010 11:04 PM
Exception handling in EJB KennedII Software Development 5 25-02-2010 04:40 AM
Exception Handling in Csharp Jesus2 Software Development 3 11-11-2009 11:22 PM


All times are GMT +5.5. The time now is 03:34 PM.