"Activation error occured while trying to get instance of type Database, key \"\""

Topics: Development Team Discussion, User Discussion
Sep 27, 2012 at 4:01 PM
Edited Sep 27, 2012 at 4:15 PM

I am trying to run the sample application described here:

http://devstuffs.wordpress.com/2012/03/13/enterprise-library-5-with-odp-net/

and downloaded here:

http://dl.dropbox.com/u/6963935/samples/EntLib5_ODP.NET/EntLib5ODP.NET.zip

I have modified the DefaultConnectionString to use our remote oracle database which is defined in the 'tnsnames.ora'.  We are running Oracle9i Release 2 Provider for OLE DB Version 9.2.0.7.0 (including ODAC) from

http://www.oracle.com/technetwork/database/windows/utilsoft-088126.html

It is installed C:\Oracle\ora92.  The 'tnsnames.ora' and 'sqlnet.ora' files were copied into C:\ORACLE\ora92\network\ADMIN.  We would like to upgrade our ASP.NET web application from MS Enterprise Library 1.1 to 5.0.

Q. Do I need to change the reference in the EntLib5Oracle console sample soln to use C:\ORACLE\ora92\bin\Oracle.DataAccess.dll?

When I run I get exception: "Activation error occured while trying to get instance of type Database, key \"\"".

Inner exception:

{"Resolution of the dependency failed, type = \"Microsoft.Practices.EnterpriseLibrary.Data.Database\", name = \"(none)\".\r\nException occurred while: Calling constructor EntLibContrib.Data.OdpNet.OracleDatabase(System.String connectionString, System.Collections.Generic.IEnumerable`1[[EntLibContrib.Data.OdpNet.IOraclePackage, EntLibContrib.Data.OdpNet, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null]] packages, Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.IDataInstrumentationProvider instrumentationProvider).\r\nException is: TypeInitializationException - The type initializer for 'EntLibContrib.Data.OdpNet.OracleDatabase' threw an exception.\r\n-----------------------------------------------\r\nAt the time of the exception, the container was:\r\n\r\n  Resolving EntLibContrib.Data.OdpNet.OracleDatabase,DefaultConnectionString (mapped from Microsoft.Practices.EnterpriseLibrary.Data.Database, (none))\r\n  Calling constructor EntLibContrib.Data.OdpNet.OracleDatabase(System.String connectionString, System.Collections.Generic.IEnumerable`1[[EntLibContrib.Data.OdpNet.IOraclePackage, EntLibContrib.Data.OdpNet, Version=5.0.505.0, Culture=neutral, PublicKeyToken=null]] packages, Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.IDataInstrumentationProvider instrumentationProvider)\r\n"}

Failing line: UserData(),  line 17, database = EnterpriseLibraryContainer.Current.GetInstance<Database>();

Since the inner exception is EntLibContrib.Data.OdpNet.OracleDatabase I'm directing this question to you.  Please advise.. Thank you...