Type initializer for DatabaseConfigurationView threw an exception

Topics: Data Access Application Block
Mar 12, 2007 at 7:17 PM
Hope someone can point me in the right direction. Have a dll I wrote that runs fine in VS2005 and is configured to register itself thru COM. When I try and run the program as a com object, i get a "The type initializer for Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView threw and exception." I'm using Enterprise Library 2.0
Mar 13, 2007 at 1:47 PM
Typically when you get a type initializer error in means an error has occurred in the running of a static constructor or initialization of static variables in the type.

The problem is probably occurring in the initialization of 3 static variables in DatabaseConfigurationView that also use the DbProviderMapping Class:

private static readonly DbProviderMapping defaultSqlMapping = new DbProviderMapping(DbProviderMapping.DefaultSqlProviderName, typeof(SqlDatabase));
private static readonly DbProviderMapping defaultOracleMapping = new DbProviderMapping(DbProviderMapping.DefaultOracleProviderName, typeof(OracleDatabase));
private static readonly DbProviderMapping defaultGenericMapping = new DbProviderMapping(DbProviderMapping.DefaultGenericProviderName, typeof(GenericDatabase));

As to why, I don't know, but maybe it will help hunt down the problem.




David Hayden
Microsoft MVP C#