我使用企業庫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幫助我找到了,我會一直錯了...