Activation error occured while trying to get instance of type ExceptionPolicyImpl, key "LoggingPolicy"

Topics: Building and extending application blocks, Data Access Application Block, Enterprise Library Core, Logging Application Block
Apr 27, 2011 at 7:16 AM

Just to simplify the process to utilize Enterprise library Exception handling and logging blocks features, we have created one single dll using Ilmerge and included all the required enterprise library dlls.

Every thing is working fine except Database logging feature.

If we include "Database trace listener" then our program throws following error. Other logging options(flat file, rolling flat file etc) are working fine.

Activation error occured while trying to get instance of type ExceptionPolicyImpl, key "LoggingPolicy".

Inner exception

+  InnerException {"Resolution of the dependency failed, type = \"Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl\", name = \"LoggingPolicy\".\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.ExceptionHandling.ExceptionPolicyImpl,LoggingPolicy\r\n  Resolving parameter \"policyEntries\" of constructor Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl(System.String policyName, System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry, ExceptionAndLoggingBlock, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null]] policyEntries)\r\n    Resolving Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry,LoggingPolicy.All Exceptions\r\n    Resolving parameter \"handlers\" of constructor Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyEntry(System.Type exceptionType, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.PostHandlingAction postHandlingAction, System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.IExceptionHandler, ExceptionAndLoggingBlock, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null]] handlers, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Instrumentation.IExceptionHandlingInstrumentationProvider instrumentationProvider)\r\n      Resolving Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler,LoggingPolicy.All Exceptions.Logging Exception Handler (mapped from Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.IExceptionHandler, LoggingPolicy.All Exceptions.Logging Exception Handler)\r\n      Resolving parameter \"writer\" of constructor Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler(System.String logCategory, System.Int32 eventId, System.Diagnostics.TraceEventType severity, System.String title, System.Int32 priority, System.Type formatterType, Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter writer)\r\n        Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl,LogWriter.__default__ (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, (none))\r\n        Resolving parameter \"structureHolder\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl(Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder structureHolder, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator updateCoordinator)\r\n          Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder,LogWriterStructureHolder.__default__ (mapped from Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder, (none))\r\n          Resolving parameter \"traceSources\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterStructureHolder(System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.Logging.Filters.ILogFilter, ExceptionAndLoggingBlock, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null]] filters, System.Collections.Generic.IEnumerable`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceSourceNames, System.Collections.Generic.IEnumerable`1[[Microsoft.Practices.EnterpriseLibrary.Logging.LogSource, ExceptionAndLoggingBlock, Version=5.0.414.0, Culture=neutral, PublicKeyToken=null]] traceSources, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource allEventsTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource notProcessedTraceSource, Microsoft.Practices.EnterpriseLibrary.Logging.LogSource errorsTraceSource, System.String defaultCategory, System.Boolean tracingEnabled, System.Boolean logWarningsWhenNoCategoriesMatch, System.Boolean revertImpersonation)\r\n            Resolving Microsoft.Practices.EnterpriseLibrary.Logging.LogSource,General\r\n            Resolving parameter \"traceListeners\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.LogSource(System.String name, System.Collections.Generic.IEnumerable`1[[System.Diagnostics.TraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] traceListeners, System.Diagnostics.SourceLevels level, System.Boolean autoFlush, Microsoft.Practices.EnterpriseLibrary.Logging.Instrumentation.ILoggingInstrumentationProvider instrumentationProvider)\r\n              Resolving Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper,Database Trace Listener (mapped from System.Diagnostics.TraceListener, Database Trace Listener)\r\n              Resolving parameter \"wrappedTraceListener\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.ReconfigurableTraceListenerWrapper(System.Diagnostics.TraceListener wrappedTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.ILoggingUpdateCoordinator coordinator)\r\n                Resolving Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener,Database Trace Listener‌implementation (mapped from System.Diagnostics.TraceListener, Database Trace Listener‌implementation)\r\n                Resolving parameter \"database\" of constructor Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener(Microsoft.Practices.EnterpriseLibrary.Data.Database database, System.String writeLogStoredProcName, System.String addCategoryStoredProcName, Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter formatter)\r\n                  Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,Connection String\r\n"} System.Exception {Microsoft.Practices.Unity.ResolutionFailedException}

 

StackTrace 
----------------------------------------------------------------------------------------------------------------------
"   at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)\r\n   at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key)\r\n   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName)\r\n   at Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)\r\n   at DemoProject.Form1.TestFunction(String policyname) in D:\\EntLib\\DemoProject\\DemoProject\\Form1.cs:line 51\r\n   at DemoProject.Form1.btnDbPolicy_Click(Object sender, EventArgs e) in D:\\EntLib\\DemoProject\\DemoProject\\Form1.cs:line 103" string

Please help.

Thanks.

 

 

 

 

 

Apr 27, 2011 at 7:51 AM

Hi,

It seems like a referencing issue to me. Are you getting the same exception before you use the IlMerged? From what I've understood, you added the Database Trace Listener after you created that single dll. Have you checked if Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll is included to those required dlls?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 27, 2011 at 8:09 AM
Edited Apr 28, 2011 at 11:34 AM

Yes I have included Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll in merged dll.

 

From: AvanadeSupport [email removed]
Sent: Wednesday, April 27, 2011 12:21 PM
To: Smita Jagtap
Subject: Re: Activation error occured while trying to get instance of type ExceptionPolicyImpl, key "LoggingPo... [entlib:255380]

 

From: AvanadeSupport

Hi,

It seems like a referencing issue to me. Are you getting the same exception before you use the IlMerged? From what I've understood, you added the Database Trace Listener after you created that single dll. Have you checked if Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll is included to those required dlls?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com


This message contains information that may be privileged or confidential and is the property of the  It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. does not accept any liability for virus infected mails.

Apr 27, 2011 at 8:35 AM

Have you added the Data Access Block and point your Database Trace Listener there? To make sure, can you post your relevant config here?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 27, 2011 at 9:41 AM
Edited Apr 28, 2011 at 11:43 AM

 

Following are the config file details

 

<?xml version="1.0"?>

<configuration> 

<configSections> 

<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings,ExceptionAndLoggingBlock" requirePermission="true"/>

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, ExceptionAndLoggingBlock" requirePermission="true"/>

<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, ExceptionAndLoggingBlock" requirePermission="true"/>

</configSections> 

 

 

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">

 

<listeners> 

 

<add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, ExceptionAndLoggingBlock" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, ExceptionAndLoggingBlock" databaseInstanceName="Connection String" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" formatter="Text Formatter" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"/>

 

</listeners> 

<formatters> 

<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, ExceptionAndLoggingBlock" template="Timestamp: {timestamp}{newline}

Message: {message}{newline} 

Category: {category}{newline} 

Priority: {priority}{newline} 

EventId: {eventid}{newline} 

Severity: {severity}{newline} 

Title:{title}{newline} 

Machine: {localMachine}{newline} 

App Domain: {localAppDomain}{newline} 

ProcessId: {localProcessId}{newline}

Process Name: {localProcessName}{newline}

Thread Name: {threadName}{newline}

Win32 ThreadId:{win32ThreadId}{newline}

Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter"/>

</formatters>

<categorySources>

<add switchValue="All" name="General">

<listeners>

<add name="Database Trace Listener"/>

</listeners>

</add>

</categorySources>

<specialSources>

<allEvents switchValue="All" name="All Events">

<listeners>

<add name="Database Trace Listener"/>

</listeners>

</allEvents>

<notProcessed switchValue="All" name="Unprocessed Category">

<listeners>

<add name="Database Trace Listener"/>

</listeners>

</notProcessed>

<errors switchValue="All" name="Logging Errors & Warnings">

<listeners>

<add name="Database Trace Listener"/>

</listeners>

</errors>

</specialSources>

</loggingConfiguration>

 

 

<exceptionHandling>

<exceptionPolicies>

<add name="LoggingPolicy">

<exceptionTypes>

<add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow">

<exceptionHandlers>

<add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, ExceptionAndLoggingBlock" logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, ExceptionAndLoggingBlock" priority="0"/>

</exceptionHandlers>

</add>

</exceptionTypes>

</add>

</exceptionPolicies>

</exceptionHandling>

 

 

<dataConfiguration defaultDatabase="Connection String"/>

<connectionStrings>

<add name="Connection String" connectionString="Data Source=xyz;Initial Catalog=Logging;User ID=sa;password=atlas123" providerName="System.Data.SqlClient"/>

</connectionStrings>

 

 

 

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

 

Thanks,

 

Smita Jagtap

 

 

From: AvanadeSupport [email removed]
Sent: Wednesday, April 27, 2011 1:05 PM
To: Smita Jagtap
Subject: Re: Activation error occured while trying to get instance of type ExceptionPolicyImpl, key "LoggingPo... [entlib:255380]

 

From: AvanadeSupport

Have you added the Data Access Block and point your Database Trace Listener there? To make sure, can you post your relevant config here?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Apr 27, 2011 at 10:50 AM

I tried copying the config but I can't open it using the Config Editor. I might be missing something here. Anyways, it would be nice if you can send us a small repro project.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 27, 2011 at 1:48 PM
FILE QUARANTINED

The original contents of this file have been replaced with
this message because of its characteristics.
File name: 'winmail.dat'
Virus name: 'ExceedinglyInfected'
Apr 27, 2011 at 2:01 PM
Edited Apr 27, 2011 at 2:03 PM

I have sent you a mail with a sample project but somehow it got quarantined. Please let me know if you have received the sample project over the mail.

Apr 28, 2011 at 2:26 AM

We haven't received your sample application until now.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 28, 2011 at 11:42 AM

Hi,

I am not able to send project file. So I am sending Command which i have used to Merge dlls. Following is the command

ILMerge /t:library /ndebug /out:..\..\..\..\Binaries\ExceptionAndLoggingBlock\ExceptionAndLoggingBlock.dll Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.EnterpriseLibrary.Data.dll Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll Microsoft.Practices.EnterpriseLibrary.Logging.dll Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll Microsoft.Practices.ServiceLocation.dll Microsoft.Practices.Unity.Configuration.dll Microsoft.Practices.Unity.dll Microsoft.Practices.Unity.Interception.Configuration.dll Microsoft.Practices.Unity.Interception.dll

And following are the dlls that I have included while merging into single dll (also mentioned in above command )

  1. Microsoft.Practices.EnterpriseLibrary.Common.dll
  2. Microsoft.Practices.EnterpriseLibrary.Data.dll
  3. Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.dll
  4. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
  5. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
  6. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll
  7. Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
  8. Microsoft.Practices.EnterpriseLibrary.Logging.dll
  9. Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll
  10. Microsoft.Practices.ServiceLocation.dll
  11. Microsoft.Practices.Unity.Configuration.dll Microsoft.Practices.Unity.dll
  12. Microsoft.Practices.Unity.Interception.Configuration.dll Microsoft.Practices.Unity.Interception.dll

 

I am sending app.config file

* I am not using Enterprise library Designer

Thank you


	
		
		
		
	


	

		

			

		
		
			
		
		
			
				
					
				
			
		
		
			
				
					
				
			
			
				
					
				
			
			
				
					
				
			
		
	


	
		
			
				
					
						
							
						
					
				
			
		
	


	
	
		
	




Apr 29, 2011 at 11:18 AM
Edited Apr 29, 2011 at 11:22 AM

 

 We were able to reproduce your problem. Found out it is affected by this known issue #26903. As workaround you can modify your config to:

 

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings,ExceptionAndLoggingBlock" requirePermission="true"/>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, ExceptionAndLoggingBlock" requirePermission="true"/>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, ExceptionAndLoggingBlock" requirePermission="true"/>
    <section name="typeRegistrationProvidersConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.TypeRegistrationProvidersConfigurationSection, ExceptionAndLoggingBlock"/>
  </configSections>
  <typeRegistrationProvidersConfiguration>
    <remove name="Data Access" />
    <add name="Data Access" providerType="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings, ExceptionAndLoggingBlock" />
    </typeRegistrationProvidersConfiguration>
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, ExceptionAndLoggingBlock" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, ExceptionAndLoggingBlock" databaseInstanceName="Connection String" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" formatter="Text Formatter" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"/>
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, ExceptionAndLoggingBlock" template="Timestamp: {timestamp}{newline}
          Message: {message}{newline} 
          Category: {category}{newline} 
          Priority: {priority}{newline} 
          EventId: {eventid}{newline} 
          Severity: {severity}{newline} 
          Title:{title}{newline} 
          Machine: {localMachine}{newline} 
          App Domain: {localAppDomain}{newline} 
          ProcessId: {localProcessId}{newline}
          Process Name: {localProcessName}{newline}
          Thread Name: {threadName}{newline}
          Win32 ThreadId:{win32ThreadId}{newline}
          Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter"/>
    </formatters>
    <categorySources>
      <add switchValue="All" name="General">
        <listeners>
          <add name="Database Trace Listener"/>
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events">
        <listeners>
          <add name="Database Trace Listener"/>
        </listeners>
      </allEvents>
      <notProcessed switchValue="All" name="Unprocessed Category">
        <listeners>
          <add name="Database Trace Listener"/>
        </listeners>
      </notProcessed>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Database Trace Listener"/>
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="LoggingPolicy">
        <exceptionTypes>
          <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow">
            <exceptionHandlers>
              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, ExceptionAndLoggingBlock" logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, ExceptionAndLoggingBlock" priority="0"/>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  <dataConfiguration defaultDatabase="Connection String"/>
  <connectionStrings>
    <add name="Connection String" connectionString="Data Source=.;Initial Catalog=Logging;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

 

HTH.

 

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


Apr 29, 2011 at 12:02 PM

hi,

It's working without any problem.

Thank you so much...

May 17, 2011 at 10:43 AM

Hi

I am also getting same problem. Here is Web.config file

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
      <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        source="Enterprise Library Logging" formatter="Text Formatter"
        log="Database Trace Listener" machineName="" traceOutputOptions="Callstack" />
      <add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        databaseInstanceName="MyDBConnectionKey" writeLogStoredProcName="WriteLog"
        addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
        traceOutputOptions="Callstack" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        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>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Event Log Listener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="General Policy">
        <exceptionTypes>
          <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            postHandlingAction="NotifyRethrow">
            <exceptionHandlers>
              <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
                priority="0" />
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
  <dataConfiguration defaultDatabase="MyDBConnectionKey">
    <providerMappings>
      <clear />
    </providerMappings>
  </dataConfiguration>
  <connectionStrings>
    <add name="MyDBConnectionKey" connectionString="Data Source=EEEPC0138;Initial Catalog=Hotel;Persist Security Info=False;User ID=sa;Password=******"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <enterpriseLibrary.ConfigurationSource selectedSource="typeRegistrationProvidersConfiguration"
    parentSource="typeRegistrationProvidersConfiguration">
    <sources>
      <add name="typeRegistrationProvidersConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MyDBConnectionKey"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="MyDBConnectionKey" applicationName="/"/>
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="MyDBConnectionKey" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>


Am getting exception from below code

private static string CONNECTION_STRING_KEY = "MyDBConnectionKey";
		public DataSet GetDataSet(string sprocedureName)
		{
			// Create the Database object, using the default database service. The
			// default database service is determined through configuration.
			DataSet objectsDataSet = null;
			try
			{
				Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>(CONNECTION_STRING_KEY);
				//Database db = DatabaseFactory.CreateDatabase(CONNECTION_STRING_KEY);
				//Database db = DatabaseFactory.CreateDatabase();
				DbCommand dbCommand = db.GetStoredProcCommand(sprocedureName);
				// DataSet that will hold the returned results		

				objectsDataSet = db.ExecuteDataSet(dbCommand);
				// Note: connection was closed by ExecuteDataSet method call 
			}
			catch (Exception e)
			{

			}
			return objectsDataSet;
		}		
plz help me out!!!!!!

May 17, 2011 at 10:47 AM

Hi Lotus,

Have you checked the scenarios I've replied to your email? Let me know, if any of the scenarios didn't worked for you.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

May 17, 2011 at 11:26 AM
Edited May 17, 2011 at 12:28 PM

Can you please send me exception details.

 

 

May 18, 2011 at 3:50 PM

@Noel- I have tried all scenarios as you replied but didn't work

@smitajagtap - below is exception details

 

Microsoft.Practices.ServiceLocation.ActivationException was caught
  Message=Activation error occured while trying to get instance of type Database, key "MyDBConnectionKey"
  Source=Microsoft.Practices.ServiceLocation
  StackTrace:
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
       at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key)
       at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String name)
       at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase(String name)
       at EnterprisesLibDemo._Default.GetDataSet(String sprocedureName) in C:\DemoProjects\EnterprisesLibDemo\EnterprisesLibDemo\Default.aspx.cs:line 41
  InnerException: Microsoft.Practices.Unity.ResolutionFailedException
       Message=Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "MyDBConnectionKey".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Database cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,MyDBConnectionKey

       Source=Microsoft.Practices.Unity
       NameRequested=MyDBConnectionKey
       TypeRequested=Database
       StackTrace:
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
            at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides)
            at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
            at Microsoft.Practices.Unity.UnityServiceLocator.DoGetInstance(Type serviceType, String key)
            at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
       InnerException: System.InvalidOperationException
            Message=The type Database cannot be constructed. You must configure the container to supply this value.
            Source=Microsoft.Practices.Unity
            StackTrace:
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext context, SelectedConstructor selectedConstructor)
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext context, NamedTypeBuildKey buildKey)
                 at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                 at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                 at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
            InnerException: 

reply

May 18, 2011 at 5:36 PM

Kindly send us a sample repro project of your issue. Thanks

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 25, 2011 at 10:08 AM

hi

                   I am using Cache Application block of Enterprise library 5.0 in my project.

                   Its wokring fine with in-memory cache and Isolated Storage cache but giving exception for Data Cache Storage.

Exception deatils:

                  The type 'Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database,

                  Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.

May 25, 2011 at 10:40 AM

Hi,

Can you check on your project's properties if the Target Platform is set to Full .Net Framework instead of .NET client profile?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 25, 2011 at 10:46 AM

I have checked project's properties,target platform is .net framework 3.5

May 25, 2011 at 11:00 AM

Would you mind if you can send us a repro project? Send it at entlib.support@avanade.com.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 25, 2011 at 11:18 AM

hi,

        Actually in last post i have tried to send you project but  i was not able to send you project file.

       Here i am sending my app.config file.

<!--?xml version="1.0"?-->



    
    
    
    





    
        
	
    
        
    
    
        
            
                
                
            
        
    
    
        
            
                
          
            
        
        
        
            
                
            
        
    


    
        
            
                
                    
                        
                    
                
                
                    
                        
                    
                
            
        
        
            
                
                    
                        
                    
                
            
        
        
            
                
                    
                        
                    
                
            
        
    



    


	
		
	
	
		
		
	
	

	
		


May 25, 2011 at 11:31 AM

The config was not pasted. Anyway, you can zip the solution and change the extension to .txt and try to send it to us.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 25, 2011 at 11:46 AM
FILE QUARANTINED

The original contents of this file have been replaced with
this message because of its characteristics.
File name: 'winmail.dat'
Virus name: 'ExceedinglyInfected'
May 25, 2011 at 12:03 PM

Too bad you can't send it or even pasting the config here. Anyway, I assume that you are still using ILMerge, then you can check if Microsoft.Practices.EnterpriseLibrary.Caching.Database.dll is included to the merged dll.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 25, 2011 at 1:11 PM

hi

         This time i am not using ILMerge. I have added  "Microsoft.Practices.EnterpriseLibrary.Caching.Database.dll " in my project.

          Now i am getting Activation error

         Activation error occured while trying to get instance of type ICacheManager, key "CacheManager1"

         Here i am sending my contig file.

<?xml version="1.0"?>
<configuration>
<configSections>
   
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>




<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
    <listeners>
        <add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            fileName="D:\EntLib\Messages\EntLibmsgFile.log" formatter="Text Formatter"
            traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
    </listeners>
    <formatters>
        <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            template="Timestamp: {timestamp}{newline}&#xD;&#xA;Message: {message}{newline}&#xD;&#xA;Category: {category}{newline}&#xD;&#xA;Priority: {priority}{newline}&#xD;&#xA;EventId: {eventid}{newline}&#xD;&#xA;Severity: {severity}{newline}&#xD;&#xA;Title:{title}{newline}&#xD;&#xA;Machine: {localMachine}{newline}&#xD;&#xA;App Domain: {localAppDomain}{newline}&#xD;&#xA;ProcessId: {localProcessId}{newline}&#xD;&#xA;Process Name: {localProcessName}{newline}&#xD;&#xA;Thread Name: {threadName}{newline}&#xD;&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
            name="Text Formatter" />
    </formatters>
    <categorySources>
        <add switchValue="All" name="General">
            <listeners>
                <add name="Flat File Trace Listener" />
              
            </listeners>
        </add>
    </categorySources>
    <specialSources>
        <allEvents switchValue="All" name="All Events">
            <listeners>
                <add name="Flat File Trace Listener" />
               
            </listeners>
        </allEvents>
        <notProcessed switchValue="All" name="Unprocessed Category" />
        <errors switchValue="All" name="Logging Errors &amp; Warnings">
            <listeners>
                <add name="Flat File Trace Listener" />
            </listeners>
        </errors>
    </specialSources>
</loggingConfiguration>
<exceptionHandling>
    <exceptionPolicies>
        <add name="ReplacePolicy">
            <exceptionTypes>
                <add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    postHandlingAction="ThrowNewException">
                    <exceptionHandlers>
                        <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                            exceptionMessage="Replaced Message." replaceExceptionType="System.Exception" />
                    </exceptionHandlers>
                </add>
                <add name="DivideByZeroException" type="System.DivideByZeroException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    postHandlingAction="ThrowNewException">
                    <exceptionHandlers>
                        <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                            exceptionMessage="Devide by zero Exception message" replaceExceptionType="System.Exception" />
                    </exceptionHandlers>
                </add>
            </exceptionTypes>
        </add>
        <add name="WrapPolicy">
            <exceptionTypes>
                <add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    postHandlingAction="ThrowNewException">
                    <exceptionHandlers>
                        <add name="Wrap Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                            exceptionMessage="&quot;wrapped Exception message &quot;"
                            exceptionMessageResourceType="" exceptionMessageResourceName="Divide button"
                            wrapExceptionType="System.Exception" />
                    </exceptionHandlers>
                </add>
            </exceptionTypes>
        </add>
        <add name="LoggingPolicy">
            <exceptionTypes>
                <add name="All Exceptions" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    postHandlingAction="ThrowNewException">
                    <exceptionHandlers>
                        <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                            logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
                            formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                            priority="0" />
                    </exceptionHandlers>
                </add>
            </exceptionTypes>
        </add>
    </exceptionPolicies>
</exceptionHandling>
<dataConfiguration defaultDatabase="Connection String" />
<connectionStrings>
    <add name="Connection String" connectionString="Data Source=d256;Initial Catalog=Caching;User ID=sa;password=******"
        providerName="System.Data.SqlClient" />
</connectionStrings>
<cachingConfiguration defaultCacheManager="CacheManager1">
    <cacheManagers>
        <add name="CacheManager1" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
            numberToRemoveWhenScavenging="10" backingStoreName="Data Cache Storage" />
    </cacheManagers>
    <backingStores>
        <add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            name="NullBackingStore" />
        <add name="Data Cache Storage" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            encryptionProviderName="" databaseInstanceName="Connection String"
            partitionName="TestPartition" />
   
    </backingStores>
</cachingConfiguration>
<startup>   
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>



May 26, 2011 at 7:30 AM

I just found out you need to create the default database that is to be used by the caching block. The script can be found on the Enterprise Library source (...\EntLib50Src\Blocks\Caching\Src\Database\Scripts). There is also a hands on lab for this. I recommend you to take a look and study on it though the lab is written on the previous version. You can download it here. Hope this helps :)

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 26, 2011 at 7:40 AM

Actually i have created default database using  script located at  "...\EntLib50Src\Blocks\Caching\Src\Database\Scripts"

as you suggest , i will go through lab provided by previous version.

Thank you

 

May 26, 2011 at 7:55 AM

That's weird. Its all working on my side now. Can you check the inner exception thrown and post it here?

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 26, 2011 at 8:02 AM

Here is the inner exception:

{"Resolution of the dependency failed, type = \"Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager\", name = \"CacheManager1\".\r\nException occurred while:

Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider).\r\n

Exception is: SqlException - A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)\r\n-----------------------------------------------\r\n

At the time of the exception, the container was:\r\n\r\n  Resolving Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager,CacheManager1 (mapped from Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager,

CacheManager1)\r\n  Resolving parameter \"realCache\" of constructor Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager(Microsoft.Practices.EnterpriseLibrary.Caching.Cache realCache, Microsoft.Practices.EnterpriseLibrary.Caching.BackgroundScheduler backgroundScheduler,

Microsoft.Practices.EnterpriseLibrary.Caching.ExpirationPollTimer pollTimer)\r\n    Resolving Microsoft.Practices.EnterpriseLibrary.Caching.Cache,CacheManager1\r\n    Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore,

Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider)\r\n"}

May 26, 2011 at 8:16 AM

Looking at the exception, it seems that you have problem connecting with your database. Try fixing the connection first.

 

Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

May 26, 2011 at 10:36 AM

hi,

       now Cache Application block is working fine.

Thank you.

Nov 12, 2011 at 3:03 AM

I am getting the same issues, Data Application block is working on my local machine, but when i deployed in server it throws the same error in above

 

Thanks,

Vijay

Nov 12, 2011 at 4:03 AM

Hi Vijay,

Can you start a new thread and post your specific information (e.g. exception info, code, and config) to that thread.  Usually, the error is caused by a misconfiguration. 

 

Thanks,

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

Dec 22, 2011 at 7:13 AM

Hi,

I currently get the same error. I greatly appreciate any help.

I'm new to Logging Application Block. I'm trying to use it now.

I have a solution with a window application project and a wcf service project. When i try to call Logger.Write("something") in window application project, it works fine. 

But if i call a service method containing Logger.Write("something") from Window application, then i get this error. I have the same configuration setting for using Logging Application Block in both projects.

Thank in advance.

Dec 23, 2011 at 3:00 AM

It sounds like the service is not configured properly.  Verify your settings.  One easy way might be to copy the windows config (that is working) to the service config file
servicename.exe.config if self hosted or web.config if hosted in IIS.  

If you are still having issues I would recommend starting a new thread and post your specific information (e.g. exception info, code, and config) to that thread.   

Thanks,

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