Enterprise Library 5.0 - System.ArgumentException

Topics: Building and extending application blocks
Apr 22, 2011 at 10:53 PM

Tried to create a custom LoggingExceptionHandler and deploy it via the "basic" way. Went through the documentation several times and I have a bad feeling I'm missing something regarding how the custom handler gets hooked up to the library. Is it neccessary to use the configuration tool for deployment? There seem to be some hints in the following trace that it isn't hooked up right, but I'm unclear on what exactly I need to do. BTW, I'm trying to make the custom handler work with the sample code. Thanks for any help.

Unhandled Exception: System.ArgumentException: The type 'LogToQSExceptions, LogToQSExceptions, Version=1.0.0.0' 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) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\AssemblyQualifiedTypeNameConverter.cs:line 63
   at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.NameTypeConfigurationElement.get_Type() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\NameTypeConfigurationElement.cs:line 58
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.CustomHandlerData.<GetRegistrations>d__1.MoveNext() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\ExceptionHandling\Src\ExceptionHandling\Configuration\CustomHandlerData.cs:line 208
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings.GetRegistrations(IConfigurationSource configurationSource) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\ExceptionHandling\Src\ExceptionHandling\Configuration\ExceptionHandlingSettings.cs:line 96
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigSectionLocator.<GetRegistrations>b__0(ITypeRegistrationsProvider p, IConfigurationSource cs) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\ConfigSectionLocator.cs:line 60
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigSectionLocator.GetRegistrationsInternal(IConfigurationSource configurationSource, Func`3 registrationsAccessor) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\ConfigSectionLocator.cs:line 88
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigSectionLocator.GetRegistrations(IConfigurationSource configurationSource) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\ConfigSectionLocator.cs:line 60
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<GetRegistrations>b__0(ITypeRegistrationsProvider l, IConfigurationSource cs) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\TypeRegistrationsProvider.cs:line 128
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<>c__DisplayClass5.<GetRegistrationsInternal>b__4(ITypeRegistrationsProvider l) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\TypeRegistrationsProvider.cs:line 147
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.RegisterAllCore(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\Unity\UnityContainerConfigurator.cs:line 61
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ChangeTrackingContainerConfigurator.RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\ChangeTrackingContainerConfigurator.cs:line 66
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\EnterpriseLibraryContainer.cs:line 83
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\EnterpriseLibraryContainer.cs:line 62
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity.EnterpriseLibraryCoreExtension.Initialize() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\Unity\EnterpriseLibraryCoreExtension.cs:line 60
   at Microsoft.Practices.Unity.UnityContainerExtension.InitializeExtension(ExtensionContext context)
   at Microsoft.Practices.Unity.UnityContainer.AddExtension(UnityContainerExtension extension)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity.EnterpriseLibraryBlockExtension.Initialize() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\Unity\EnterpriseLibraryBlockExtension.cs:line 29
   at Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Unity.ValidationBlockExtension.Initialize() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Validation\Src\Validation\Configuration\Unity\ValidationBlockExtension.cs:line 34
   at Microsoft.Practices.Unity.UnityContainerExtension.InitializeExtension(ExtensionContext context)
   at Microsoft.Practices.Unity.UnityContainer.AddExtension(UnityContainerExtension extension)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.AddValidationExtension() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\Unity\UnityContainerConfigurator.cs:line 208
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator..ctor(IUnityContainer container) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\ContainerModel\Unity\UnityContainerConfigurator.cs:line 44
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer(IConfigurationSource configurationSource) in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\EnterpriseLibraryContainer.cs:line 121
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\EnterpriseLibraryContainer.cs:line 108
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\EnterpriseLibraryContainer.cs:line 95
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.get_Current() in C:\Users\PXS\EntLib5.0\EntLib50Src\Blocks\Common\Src\Configuration\EnterpriseLibraryContainer.cs:line 36
   at ExceptionHandlingExample.Program.Main(String[] args) in G:\PXS\vs_projects\EntLib5.0\ExceptionHandling\ExceptionHandling\Program.cs:line 35

 

Apr 24, 2011 at 11:21 AM

Could you post your CustomExceptionHandler code here? Thanks. 

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 25, 2011 at 3:56 PM

Thanks for responding. I posted the trace with the hope that someone might have enough familiarity to recognize the problem by seeing this trace. Before taking the next step could we please verify that I've done everything neccessary to hook up the handler to the library? Based on this trace I don't have much confidence in the configuration. I'll ask again, is the GUI tool necessary to correctly complete the configuration? Also, could someone please point me to a concise list of steps necessary to hook the handler into the libray? This list should cover everything from code changes to modifying the config file. I am more than happy to retrace my steps, but at this point I'm not entirely sure of what all the steps should be so I'm looking for confirmation. Thanks.

Apr 26, 2011 at 3:31 AM

Hi,

My suspicion based from the error encountered is that the Custom Handler is not configured or may have some problem with the code how it was created. That's why I've asked for the Custom Handler code to confirm this.

As for the Configuration Tool it is a recommended best practice to utilize this tool to avoid typo errors and to not require to do the configuration all by hand. One good benefit of the Config Tool is when you're hooking up custom extensions for Entlib. Like for example with the Custom Exception Handler, if this is not being recognized by the Tool then this is one sign that there is something wrong with the custom handler creation.

If you would want to have a more detailed step by step on this, I would suggest looking into the Entlib 5's Extensibility Lab, there is a specific topic for the Custom Exception Handler in there. Hope this helps.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com