"The type Database cannot be constructed. You must configure the container to supply this value."

回答の候補 "The type Database cannot be constructed. You must configure the container to supply this value."

  • Thursday, March 17, 2011 1:22 PM
     
     

    I am trying to implement Exception Handling Application Block. 

    For some reason, the system returns the following message when the exception logging gets called:  "The type Database cannot be constructed. You must configure the container to supply this value."  Do you have any idea what might be causing this?  My App.config file is below:

    <?xml version="1.0" encoding="utf-8" ?>

    <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="false" />
     <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
     <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
     <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <connectionStrings>
     <add name="Appl​icationSer​vices" connectionString="Se​rver=tcp:y​gw46rq43r.​database.w​indows.net​,1433;Data​base=TSOME​MBERSHIP;U​ser ID=TSOluti​onsAdmin;P​assword=pa​55_w0rd;Tr​usted_Conn​ection=Fal​se;Encrypt​=True;" providerName="System.Data.SqlClient"/>
     <add name="LoggingDB" connectionString="Server=tcp:ygw46rq43r.database.windows.net,1433;Database=Logging;User ID=TSOlutionsAdmin;Password=pa55_w0rd;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <dataConfiguration defaultDatabase="LoggingDB" />
     
    <unity configSource="Config\Unity.config" />
     
    <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
     <listeners>
      <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="LoggingDB" writeLogStoredProcName="WriteLog"
        addCategoryStoredProcName="AddCategory" 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="Title:{tab}{tab}{title}{newline}&amp;#xA;Timestamp:{tab}{tab}{timestamp}{newline}{dictionary({key}:{tab}{value}{newline})}Category:{tab}{tab}{category}{newline}Priority:{tab}{tab}{tab}{priority}{newline}EventId:{tab}{tab}{tab}{eventid}{newline}Severity:{tab}{tab}{tab}{severity}{newline}Machine:{tab}{tab}{machine}{newline}AppDomain:{tab}{tab}{appDomain}{newline}ProcessID:{tab}{tab}{processId}{newline}ProcessName:{tab}{tab}{processName}{newline}ThreadID:{tab}{tab}{win32ThreadId}{newline}ThreadName:{tab}{tab}{threadName}{newline}{newline}***********************************************************************************************{newline}&lt;FormattedMessage&gt;&lt;Timestamp&gt;{timestamp}&lt;/Timestamp&gt;&lt;Message&gt;{message}&lt;/Message&gt;&lt;Category&gt;{category}&lt;/Category&gt;&lt;Priority&gt;{priority}&lt;/Priority&gt;&lt;EventId&gt;{eventid}&lt;/EventId&gt;&lt;Severity&gt;{severity}&lt;/Severity&gt;&lt;Title&gt;{title}&lt;/Title&gt;&lt;Machine&gt;{machine}&lt;/Machine&gt;&lt;AppDomain&gt;{appDomain}&lt;/AppDomain&gt;&lt;ProcessID&gt;{processId}&lt;/ProcessID&gt;&lt;ProcessName&gt;{processName}&lt;/ProcessName&gt;&lt;ThreadID&gt;{win32ThreadId}&lt;/ThreadID&gt;&lt;ThreadName&gt;{threadName}&lt;/ThreadName&gt;&lt;ExtendedProperties&gt;{dictionary(&lt;key&gt;{key}&lt;/key&gt;&lt;value&gt;{value}&lt;/value&gt;)}&lt;/ExtendedProperties&gt;&lt;/FormattedMessage&gt;"
        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" />
      <notProcessed switchValue="All" name="Unprocessed Category" />
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
       <listeners>
        <add name="Database Trace Listener" />
       </listeners>
      </errors>
     </specialSources>
    </loggingConfiguration>
    <exceptionHandling>
     <exceptionPolicies>
      <add name="General">
       <exceptionTypes>
        <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          postHandlingAction="None">
         <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>
      <add name="GeneralWarning">
       <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="Category 2" eventId="100" severity="Warning" 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>
    </configuration>

     

All Replies

  • Friday, June 03, 2011 6:30 AM
     
     
    Even I'm getting same problem. Have you got a resolution?. I'm getting this problem with Emterprise library 5.0
  • Thursday, June 09, 2011 2:47 PM
     
     
    same error here......is there any solution?
    Regards, Rama
  • Tuesday, August 09, 2011 8:56 AM
     
     
    I get the same error even when trying Data Access examples.
  • Friday, March 16, 2012 9:03 AM
     
     
    now  i also get this error! waiting....
  • Wednesday, April 04, 2012 6:02 PM
     
     Proposed

    Hi Esther,

    Please check this link:

    http://entlib.codeplex.com/discussions/267817ck t


    Regards, http://shwetamannjain.blogspot.com

    • Proposed As Answer by Shweta Jain Wednesday, April 04, 2012 6:02 PM
    •