<类型数据库不能被构造.您必须配置容器以提供该值. [英] "The type Database cannot be constructed. You must configure the container to supply this value."

查看:48
本文介绍了<类型数据库不能被构造.您必须配置容器以提供该值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现异常处理应用程序块.

I am trying to implement Exception Handling Application Block. 

由于某种原因,当调用异常日志记录时,系统将返回以下消息: <类型数据库不能被构造.您必须配置容器以提供该值.您是否知道可能是什么原因造成的? 我的App.config文件如下:

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" ?>

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

<配置>
< configSections>
<节名="loggingConfiguration".类型="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,Microsoft.Practices.EnterpriseLibrary.Logging,版本= 5.0.414.0,Culture =中性,PublicKeyToken = 31bf3856ad364e35". requirePermission ="false"; />
<节名="exceptionHandling".类型="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings,Microsoft.Practices.EnterpriseLibrary.ExceptionHandlingSettings,版本= 5.0.414.0,Culture =中性,PublicKeyToken = 31bf3856ad364e35". requirePermission ="false"; />
<b;<节名=联合国".类型="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,Microsoft.Practices.Unity.Configuration". />
<节名="dataConfiguration";类型="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary.Data,版本= 5.0.414.0,Culture =中性,PublicKeyToken = 31bf3856ad364e35". />
</configSections>
< connectionStrings>
 < add name ="应用服务" connectionString =" Sever = tcp:ygw46rq43r.database.windows.net,1433;数据库= TSOMEMBERSHIP; User ID = TSOlutionsAdmin; Password = pa55_w0rd ; Trusted_Connction = False; Encrypt = True;" providerName ="System.Data.SqlClient"/>
 < add name =" LoggingDB" connectionString ="Server = tcp:ygw46rq43r.database.windows.net,1433;数据库=日志记录;用户ID = TSOlutionsAdmin;密码= pa55_w0rd; Trusted_Connection = False;加密= True;"; providerName ="System.Data.SqlClient"; />
</connectionStrings>
< dataConfiguration defaultDatabase =" LoggingDB" />
 
< unity configSource =" Config \ Unity.config" />
 
< loggingConfiguration name ="" tracingEnabled ="true" defaultCategory =常规">
 <侦听器>
 < add name =数据库跟踪监听器" type ="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener,Microsoft.Practices.EnterpriseLibrary.Logging.Database,版本= 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"
    listenerDataType ="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData,Microsoft.Practices.EnterpriseLibrary.Logging.Database,版本= 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"
    databaseInstanceName =" LoggingDB" writeLogStoredProcName =" WriteLog"
    addCategoryStoredProcName =" AddCategory" formatter =文本格式化程序"
    traceOutputOptions ="LogicalOperationStack,DateTime,Timestamp,ProcessId,ThreadId,Callstack". />
 </listeners>
 < formatters>
 <添加类型="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,Microsoft.Practices.EnterpriseLibrary.Logging,版本= 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"
    template ="quote:{tab} {tab} {title} {newline}& amp; #xA; Timestamp:{tab} {tab} {timestamp} {newline} {dictionary({key}:{tab} {值} {newline})}类别:{tab} {tab} {category} {newline}优先级:{tab} {tab} {tab} {priority} {newline} EventId:{tab} {tab} {tab} { eventid} {newline}严重性:{tab} {tab} {tab} {severity} {newline}机器:{tab} {tab} {machine} {newline} AppDomain:{tab} {tab} {appDomain} {newline} ProcessID:{tab} {tab} {processId} {newline} ProcessName:{tab} {tab} {processName} {newline}线程ID:{tab} {tab} {win32ThreadId} {newline} ThreadName:{tab} {tab} {threadName} {newline} {newline} ********************************************* ****************************************************** **** {newline}& lt; FormattedMessage& gt;< Timestamp& gt; {timestamp}& lt;/Timestamp& lt; Message& gt; {message}& lt; /Message& gt;< Category& gt; {category}</Category& gt;< Priority& gt; {priority}& lt;/Priority& gt;& lt; EventId& ; gt; {eventid}& lt;/EventId& gt;& lt; Seve rity& gt; {severity}</Severity& gt;< Title& gt; {title}</Title& lt; Machine& gt; {machine}& lt ;/Machine& lt; AppDomain& gt; {appDomain}& lt;/AppDomain& gt;& lt; ProcessID> {processId}& lt;/ProcessID>< ProcessName> {processName}</ProcessName& gt;& lt; ThreadID& gt; {win32ThreadId}& lt;/ThreadID>& lt; ThreadName& gt; {threadName}& lt ;/ThreadName>& 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 =文本格式化程序"; />
 </formatters>
 < categorySources>
  < add switchValue ="All"名称=常规">
  < listeners>
   < add name =数据库跟踪侦听器" />
  </listeners>
  </add>
 </categorySources>
 < specialSources>
  < allEvents switchValue =全部" name =所有事件" />
  < notProcessed switchValue ="All" name =未处理的类别"; />
 <错误switchValue =所有" name ="记录错误& amp;警告">
  < listeners>
   < add name =数据库跟踪侦听器" />
  </listeners>
  </errors>
 </specialSources>
</loggingConfiguration>
< exceptionHandling>
 < exceptionPolicies>
  < add name ="General">
  <b; exceptionTypes>
   < add name =所有例外";类型="System.Exception,mscorlib,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089"
     postHandlingAction =无">
    < exceptionHandlers>
    < add name =日志记录异常处理程序";类型="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,版本= 5.0.414.0,文化=中性, PublicKeyToken = 31bf3856ad364e35"
       logCategory =常规". eventId ="100"严重性=错误"; title =企业库异常处理"
       formatterType ="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,版本= 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"
      优先级="0". />
    </exceptionHandlers>
   </add>
  </exceptionTypes>
  </add>
  < add name ="GeneralWarning">
  <b; exceptionTypes>
   < add name =所有例外";类型="System.Exception,mscorlib,版本= 4.0.0.0,区域性=中性,PublicKeyToken = b77a5c561934e089"
     postHandlingAction ="NotifyRethrow">
    < exceptionHandlers>
    < add name =日志记录异常处理程序";类型="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,版本= 5.0.414.0,文化=中性, PublicKeyToken = 31bf3856ad364e35"
       logCategory =类别2". eventId ="100"严重性=警告". title =企业库异常处理"
       formatterType ="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,版本= 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"
      优先级="0". />
    </exceptionHandlers>
   </add>
  </exceptionTypes>
  </add>
 </exceptionPolicies>
</exceptionHandling>
</configuration>

<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>

 

推荐答案

即使我遇到了同样的问题.你有解决方案吗?我在Emterprise库5.0中遇到了这个问题
Even I'm getting same problem. Have you got a resolution?. I'm getting this problem with Emterprise library 5.0


这篇关于&lt;类型数据库不能被构造.您必须配置容器以提供该值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆