Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Using Enterprise Library 4.0 Exception Handling Application Block

Reply
 
Old 06-20-2008   #1 (permalink)
Polly Anna


 
 

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.ExceptionHandling.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.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.ConvertFrom(ITypeDescriptorContext
context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerData.get_ReplaceExceptionType()
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerAssembler.Assemble(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(IBuilderContext
context, ExceptionTypeData objectConfiguration, IConfigurationSource
configurationSource, ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext
context, String name, IConfigurationSource configurationSource,
ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(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.BuildUp[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


My System SpecsSystem Spec
Old 06-21-2008   #2 (permalink)
Jeff Winn


 
 

Re: Using Enterprise Library 4.0 Exception Handling Application Block

Should have read the exception message closer - it tells you exactly what
the issue is.

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF,
Version=4.0.0.0,
Quote:

> Culture=neutral, PublicKeyToken=31bf3856ad364e35'
It can't locate an assembly with that assembly name with the types specified
in 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. Since your application isn't referencing the
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll directly
when it's trying to log the exception it can't find the assembly inside the
bin folder you told it to use in your config file.

"Polly Anna" <Polly Anna@xxxxxx> wrote in message
news:567E7B3F-BBCB-4A82-8DDC-EBA5F65B4CFB@xxxxxx
Quote:

> 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.ExceptionHandling.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.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.ConvertFrom(ITypeDescriptorContext
> context, CultureInfo culture, Object value)
> at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
> at
> Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerData.get_ReplaceExceptionType()
> at
> Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ReplaceHandlerAssembler.Assemble(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(IBuilderContext
> context, ExceptionTypeData objectConfiguration, IConfigurationSource
> configurationSource, ConfigurationReflectionCache reflectionCache)
> at
> Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext
> context, String name, IConfigurationSource configurationSource,
> ConfigurationReflectionCache reflectionCache)
> at
> Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(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.BuildUp[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
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Exception Handling - Get-WmiObject on multiple servers PowerShell
Exception Handling Application Block .NET General
Getting Custom Source Name Using Enterprise Library Logging Block .NET General
Custom Exception Handling And Logging using EnterPrise Library app .NET General
Exception handling in Vista Application Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46