2010-07-26 20 views
1

我使用企業庫5.0與SharePoint登錄異常轉換SQLdatabase.I使用Windows 7操作系統和Visual Studio 2010中例外策略與數據庫跟蹤偵聽器在企業圖書館5.0沒有記錄異常到SQL數據庫

(1)如鏈接中所示,我通過在位置(C:\ Documents and Settings \ Venkatesan \ My Documents \ EntLib50Src \ Blocks \ Logging \ Src \ DatabaseTraceListener \ Scripts \ CreateLoggingDb)中運行腳本在SQLEXPRESS中創建了「日誌記錄」數據庫

(2)我打開企業庫(EntLib Config .Net 4)中的web.config文件,並提到連接字符串爲「data source =。\」的數據庫實例(ExampleDatabase)的連接字符串。 (3)我提到了異常策略(MyPolicy),異常類型(All Exceptions),數據庫跟蹤監聽器等等。(3)SQLEXPRESS;集成安全性= SSPI; AttachDBFilename = | DataDirectory | \ Logging.mdf;用戶實例= true

上..因此web.config文件如下: 我已經在web.config文件
僅設置所需的部分.. .. .. .. .. (4)我部署所需的DLL在GAC和Web應用程序的bin以及... 以前,我沒有在GAC中部署ent lib DLL,但是我有一個錯誤提到我必須在GAC中部署它們。

(5)我在解決方案項目中添加了ent lib dlls作爲參考。

(6)我的項目代碼如下:使用系統

;
使用Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
使用Microsoft.Practices.EnterpriseLibrary.Data。SQL;
using Microsoft.Practices.EnterpriseLibrary.Data.SqlCe;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging;
使用Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Database;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.ObjectBuilder2;
使用Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using Microsoft.Practices.Unity.InterceptionExtension;
using Microsoft.Practices.Unity.InterceptionExtension.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;使用Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;

命名空間MyEntLibProj.Layouts.MyEntLibProj
{
公共部分類MyApplicationPage:LayoutsPageBase
{
保護無效的Page_Load(對象發件人,EventArgs的)
{
嘗試
{
拋出新ArgumentNullException (「這是一個錯誤!!!!」);
}
catch(Exception ex)
{
Exception ex1;
bool result = ExceptionPolicy.HandleException(ex,「MyPolicy」,out ex1);
if(result)
throw;
}
}
}
}

當我調試代碼,雖然我沒有得到任何異常,「結果」值是true,則ArgumentNull異常不獲取登錄到我database.Please幫助我找到了,我會一直錯了...

回答

0

我的web.config文件:

<配置>
< configSections>
<節名稱= 「loggingConfiguration」 類型=「Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,

Microsoft.Practices.EnterpriseLibrary.Logging,版本= 5.0.414.0,文化=中性,

公鑰= 31bf3856ad364e35" requirePermission = 「真」/>
<節名稱= 「exceptionHandling」 類型=「Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,版本= 5.0 0.414。0,文化=中性

公鑰= 31bf3856ad364e35" requirePermission = 「真」/> <節名稱= 「dataConfiguration」 類型=「Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,Microsoft.Practices.EnterpriseLibrary 。數據,版本= 5.0.414.0,文化=中性公鑰= 31bf3856ad364e35" requirePermission = 「真」/> ..
< loggingConfiguration NAME = 「」 tracingEnabled = 「真」 defaultCategory = 「常規」>
<聽衆>
< 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 =」ExampleDatabase「writeLogStoredProcName =」WriteLog「addCategoryStoredProcName =」AddCategory「formatter = 「Text Formatter」/>
<格式化程序>
< add type =「Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextF {0} {0} {0} {0} {0} {0} {0} {0} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 {} {newline} {} {{{}} {} {} {} {} {} {} {} 應用領域:{localAppDomain} {換行符} 的ProcessID:{localProcessId} {換行符} 進程名稱: {localProcessName} {換行符} 主題名稱:{threadName} {換行符} 的Win32 的ThreadId:{win32ThreadId} {換行符} 擴展屬性:{字典({鍵} - {值} {換行符})}」名稱= 「文本格式化」/> < categorySources>
<添加switchValue = 「全部」名稱= 「通用」>
<聽衆>
<添加名稱= 「數據庫跟蹤監聽器」/>


< specialSources>
< allEvents switchValue = 「所有」 NAME = 「所有事件」/ >
< notProcessed switchValue = 「全部」 名稱= 「未處理類別」/>
<錯誤switchValue = 「全部」 名稱= 「錯誤記錄&警告」/>


< exceptionHandling>
< exceptionPolicies>
<添加名稱= 「MyPolicy」>
< exceptionTypes>
<添加名稱= 「所有異常」 類型=「系統。例外,mscorlib程序,版本= 4.0.0.0,文化=中性公鑰= b77a5c561934e089" postHandlingAction = 「NotifyRethrow」> <的ExceptionHandlers>
<添加名稱= 「日誌記錄異常處理程序」 類型=「Microsoft.Practices.EnterpriseLibrary.ExceptionHandling。 Logging.LoggingExceptionHandler,Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,版本= 5.0.414.0,文化=中性公鑰= 31bf3856ad364e35" logCategory = 「常規」 事件ID = 「100」 嚴重= 「錯誤」 稱號=「企業庫 異常處理「 formatterType =」Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,Version = 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35「 優先= 「0」/> < /的ExceptionHandlers> < dataConfiguration defaultDatabase = 「ExampleDatabase」/> < connectionStrings>節點
<添加名稱= 「ExampleDatabase」 的connectionString =「數據源= \ SQLEXPRESS。綜合 安全性= SSPI; AttachDBFilename = | DataDirectory目錄| \ Logging.mdf;用戶實例=真 「的providerName = 」System.Data.SqlClient的「/> .. < SafeControls> <的SafeControl大會=」 S ystem.Web,Version = 1.0.5000.0,Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a「Namespace =」System.Web.UI.WebControls「TypeName =」「Safe =」True「AllowRemoteDesigner =」True「SafeAgainstScript =」False「 /> ..
<的SafeControl大會= 「Microsoft.Practices.EnterpriseLibrary.Common,版本= 5.0.414.0, 文化=中性公鑰= 31bf3856ad364e35」 命名空間= 「Microsoft.Practices.EnterpriseLibrary.Common」 類型名=」
「Safe =」True「/> < SafeControl Assembly =」Microsoft.Practices.Unity,Version = 2.0.414.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35「Namespace =」Microsoft.Practices.Unity「TypeName =」「安全=「真」/> <的SafeControl大會= 「Microsoft.Practices.Unity.Configuration,版本= 2.0.414.0, 文化=中性公鑰= 31bf3856ad364e35」 命名空間= 「Microsoft.Practices.Unity.Configuration」 的TypeName =」 「安全=」 真「/> < SafeControl Assembly =」Microsoft.Practices.Unity.Interception.Configuration, Version = 2.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35「 Namespace =」Microsoft.Practices.Unity.Interception.Configuration「TypeName = 「」Safe =「True」/> < SafeControl Assembly =「Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version = 5.0.414.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35」 Namespace =「Microsoft.Practices.EnterpriseLibrary.ExceptionHandling」TypeName =「」Safe =「True」/> < SafeControl Assembly =「Microsoft.Practices.EnterpriseLibrary.Logging,Version = 5.0.414.0, Culture = neutral,PublicKeyToken = 31bf3856ad364e35" 命名空間= 「Microsoft.Practices.EnterpriseLibrary.Logging」 類型名= 「」安全=「 真」/> <的SafeControl大會=「Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, 版本= 5.0.414.0, Culture = neutral,PublicKeyToken = 31bf3856ad364e35「 Namespace =」Microsoft.Practices.EnterpriseLibrary.ExceptionHandling。記錄 「的TypeName =」 「安全=」 真 「/> <的SafeControl大會= 」Microsoft.Practices.EnterpriseLibrary.Data,版本= 5.0.414.0, 文化=中性公鑰= 31bf3856ad364e35「 命名空間=」 Microsoft.Practices .EnterpriseLibrary.Data 「的TypeName =」 「安全=」 真」 /> <的SafeControl大會= 「Microsoft.Practices.EnterpriseLibrary.Logging.Database, 版本= 5.0.414.0,文化=中性公鑰= 31bf3856ad364e35」 命名空間=「Microsoft.Practices.EnterpriseLibrary.Logging.Database」TypeName =「」Safe =「True」/> < SafeControl Assembly =「Microsoft.Practices.EnterpriseLibrary.Data.SqlCe,Version = 5.0.414.0, Culture = neutral,PublicKeyToken = 31bf3856ad364e35「 Namespace =」Microsoft.Practices.EnterpriseLibrary.Data.SqlCe「TypeName =」「Safe =」True「/> < SafeControl Assembly =」Microsoft.Practices.ServiceLocation,Version = 1.0 .0.0文化=中性, 公鑰= 31bf3856ad364e35 「命名空間=」 Microsoft.Practices.ServiceLocation 「類型名=」 「安全=」 真」 /> .. ..

相關問題