Exception type: ArgumentNullException Exception message: Value cannot be null error

Topics: General discussion
Dec 20, 2011 at 3:24 PM
Edited Dec 20, 2011 at 3:26 PM

Hi,

I'm trying to upgrade a solution of 39 projects to the .NET 4.0 framework from the 2.0 framework. The 2.0 solution utilized EntLib 2.0. I've replaced all the previous dll versions of the EntLib with the new versions (5.0), replaced all the configurations in the web.config file, and corrected all the compilation errors. The solution builds successfully, but I get the following error when attempting to use any of the EntLib blocks:

Exception information:
    Exception type: ArgumentNullException
    Exception message: Value cannot be null.
Parameter name: typeName
   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   at System.Type.GetType(String typeName)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationElementTypeAttribute.get_ConfigurationType()
   at Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.GetDatabaseData(ConnectionStringSettings connectionString, DatabaseSettings databaseSettings)
   at Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.<get_Databases>d__0.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.<DoGetRegistrations>d__10.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings.GetRegistrations(IConfigurationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeLoadingLocator.<GetRegistrations>b__0(ITypeRegistrationsProvider p, IConfigurationSource cs)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeLoadingLocator.GetRegistrationsInternal(IConfigurationSource configurationSource, Func`3 registrationAccessor)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeLoadingLocator.GetRegistrations(IConfigurationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<GetRegistrations>b__0(ITypeRegistrationsProvider l, IConfigurationSource cs)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<>c__DisplayClass5.<GetRegistrationsInternal>b__4(ITypeRegistrationsProvider l)
   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.RegisterAllCore(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ChangeTrackingContainerConfigurator.RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer(IConfigurationSource configurationSource)
   at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()
   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName)
A simple line of code that generates this error is below:

 Thanks.

dim _primitivesCache as ICacheManager = CacheFactory.GetCacheManager()
 
Dec 20, 2011 at 11:09 PM

It looks like an issue with the Database configuration.  Can you post the configuration file? 

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com

Dec 21, 2011 at 12:22 PM

Hi Randy,

    Thanks for the reply. It appears that you are correct. I stripped out all the blocks/configurations and began adding them back in, one by one. Everything is working except the data access block. The solution contains a project that extends the DAAB (Oracle database). The 2.0 code contains a custom assembler class that implements the IDatabaseAssembler interface (which is no longer used). Then a custom database class inherits from GenericDatabase with an attribute

<DatabaseAssembler(GetType(OracleODPDatabaseAssembler))>

I guess what I essentially need is direction on how to accomplish the same task with the Entlib 5.0 classes. Can you provide me with a sample on how to do this?

 

Thanks for your help.

 

Dec 21, 2011 at 2:03 PM

It sounds like you have your own database in order to use the ODP.NET provider.  If that is the case, I would recommend looking at the EntLibContrib project.  It has an ODP.NET Data Provider.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com