467,879 Members | 1,197 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,879 developers. It's quick & easy.

Using Enterprise Library 4.0 Exception Handling Application Block

Hi,

I have previously used EL v 3.1 Exception Handling application block
successfully. I thought I would now try to do the same with EL v 4.0. My
first experiment was to replace an exception.
I created a project and added the following references -

1/ Enterprise Library Exception Handling Application Block v 4.0
(Microsoft.Practices.EnterpriseLibrary.ExceptionHa ndling.dll)
2/ Enterprise Library Shared v 4.0
(Microsoft.Practices.EnterpriseLibrary.Common.dll)
3/ Microsoft.Practices.ObjectBuilder v 1.0.51206.0 (then I tried version 2
as well)(Microsoft.Practices.ObjectBuilder.dll)

I then used the Configuration Manager to create the app.config file and add
the
Replace Handler to my new policy.

I then added simple code in my application (see below) that uses the
ExceptionPolicy.HandleException of EL.

Unfortunately I get the error below and I can't figure out what is wrong.

Please can someone point me in the right direction. I really would
appreciate any help.

Kind regards,

Polly Anna

Application 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.ExceptionHan dling.ExceptionHandlingException:
The current build operation (build key Build
Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyImpl,
Replace Policy]) failed: The type
'Microsoft.Practices.EnterpriseLibrary.ExceptionHa ndling.WCF.FaultContractWrapperException,
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.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.Confi guration.ObjectBuilder.ConfiguredObjectStrategy,
index 2) ---Microsoft.Practices.ObjectBuilder2.BuildFailedExce ption: The
current build operation (build key Build
Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyImpl,
Replace Policy]) failed: The type
'Microsoft.Practices.EnterpriseLibrary.ExceptionHa ndling.WCF.FaultContractWrapperException,
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.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.Confi guration.ObjectBuilder.ConfiguredObjectStrategy,
index 2) ---System.ArgumentException: The type
'Microsoft.Practices.EnterpriseLibrary.ExceptionHa ndling.WCF.FaultContractWrapperException,
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.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.Confi guration.AssemblyQualifiedTypeNameConverter.Conver tFrom(ITypeDescriptorContext
context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Ob ject value)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Configuration.ReplaceHandlerData.get_Replace ExceptionType()
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Configuration.ReplaceHandlerAssembler.Assemb le(IBuilderContext
context, ExceptionHandlerData objectConfiguration, IConfigurationSource
configurationSource, ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.AssemblerBasedObjectFactory `2.Create(IBuilderContext
context, TConfiguration objectConfiguration, IConfigurationSource
configurationSource, ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyEntryCustomFactory.Create(IBu ilderContext
context, ExceptionTypeData objectConfiguration, IConfigurationSource
configurationSource, ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyCustomFactory.CreateObject(IB uilderContext
context, String name, IConfigurationSource configurationSource,
ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.ConfiguredObjectStrategy.Pr eBuildUp(IBuilderContext context)
at
Microsoft.Practices.ObjectBuilder2.StrategyChain.E xecuteBuildUp(IBuilderContext context)
--- End of inner exception stack trace ---
at
Microsoft.Practices.ObjectBuilder2.StrategyChain.E xecuteBuildUp(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.Confi guration.ObjectBuilder.EnterpriseLibraryFactory.Bu ildUp[T](IReadWriteLocator
locator, ILifetimeContainer lifetimeContainer, String id,
IConfigurationSource configurationSource)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.LocatorNameTypeFactoryBase` 1.Create(String name)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicy.GetExceptionPolicy(Exception
exception, String policyName, ExceptionPolicyFactory factory)
--- End of inner exception stack trace ---
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicy.GetExceptionPolicy(Exception
exception, String policyName, ExceptionPolicyFactory factory)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicy.HandleException(Exception
exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.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

Jun 27 '08 #1
  • viewed: 2081
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by belius | last post: by
9 posts views Thread by reshugoyal | last post: by
1 post views Thread by Anonieko | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.