Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type Database, key ""

Topics: Data Access Application Block
Oct 25, 2012 at 10:14 AM
Edited Oct 25, 2012 at 10:18 AM

hi all,

having a problem of having the web application running normally at by both development laptop.(64bit) and development 2008R2server (32bit). hoewever when moved to a web server running windows 2008 R2 64bit, when it calls for the

 

  Database db = DatabaseFactory.CreateDatabase();

 

it produces an exception of:

[Microsoft.Practices.ServiceLocation.ActivationException] = {"Activation error occured while trying to get instance of type Database, key \"\""}

inner exception of:

 {"Resolution of the dependency failed, type = \"Microsoft.Practices.EnterpriseLibrary.Data.Database\", name = \"(none)\".\r\nException occurred while: while resolving.\r\nException is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.\r\n-----------------------------------------------\r\nAt the time of the exception, the container was:\r\n\r\n  Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)\r\n"}

 

below is my part of my web.config:

?xml version="1.0"?><configuration>
	<configSections>
  <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" requirePermission="true" />
  <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" requirePermission="true" />
  <section name="oracleConnectionSettings" type="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.Configuration.OracleConnectionSettings, Microsoft.Practices.EnterpriseLibrary.Data" requirePermission="true"/>
  <!--<section name="typeRegistrationProvider" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.TypeRegistrationProvidersConfigurationSection, Microsoft.Practices.EnterpriseLibrary.Common" />-->
  <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
				</sectionGroup>
			</sectionGroup>
		</sectionGroup>
	</configSections>
  <oracleConnectionSettings>
  <add name="myOracleConnectionString" />
 </oracleConnectionSettings>
  
 <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
     <listeners>
         <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
             listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
             source="Enterprise Library Logging" formatter="Text Formatter"
             log="test1" machineName="" traceOutputOptions="None" />
     </listeners>
     <formatters>
         <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
             template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
             name="Text Formatter" />
     </formatters>
     <categorySources>
         <add switchValue="All" name="General">
             <listeners>
                 <add name="Event Log Listener" />
             </listeners>
         </add>
         <add switchValue="All" name="Information">
             <listeners>
                 <add name="Event Log Listener" />
             </listeners>
         </add>
     </categorySources>
     <specialSources>
         <allEvents switchValue="All" name="All Events">
             <listeners>
                 <add name="Event Log Listener" />
             </listeners>
         </allEvents>
         <notProcessed switchValue="All" name="Unprocessed Category">
             <listeners>
                 <add name="Event Log Listener" />
             </listeners>
         </notProcessed>
         <errors switchValue="All" name="Logging Errors &amp; Warnings">
             <listeners>
                 <add name="Event Log Listener" />
             </listeners>
         </errors>
     </specialSources>
 </loggingConfiguration>
 <dataConfiguration defaultDatabase="myOracleConnectionString">
     <providerMappings>
         <add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data"
             name="Oracle.DataAccess.Client" />
     </providerMappings>
 </dataConfiguration>
 <connectionStrings>
     <add name="myOracleConnectionString" connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=LASUSR)));User Id=las;Password=abcdefg;"
         providerName="Oracle.DataAccess.Client" />
     <add name="savefilepath" connectionString="c:/rlasdownload" />
 </connectionStrings>

 

 

 

i was looking over the internet and many proposed of wrong DLL but i am pretty sure of having the right DLL. ..would anyone help cause i am pretty much stuck by this

 

regards,

martin

Oct 26, 2012 at 6:26 AM

I would guess that the DbProviderFactory for Oracle is not configured in machine.config. See http://entlib.codeplex.com/discussions/394482.

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

Oct 29, 2012 at 10:21 AM
randylevy wrote:

I would guess that the DbProviderFactory for Oracle is not configured in machine.config. See http://entlib.codeplex.com/discussions/394482.

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

thanks that saved me.

regards,

martin