2008-12-17 35 views
1

我編寫了一個CLR存儲過程(列於下面) 僅添加了用於引發異常的代碼行 在EventLog中記錄了異常 我部署了程序集開創了數據庫 存儲的過程然而,當我執行存儲過程的條目在Windows的事件日誌調用.NET類實例的CLR存儲過程

如果在事件日誌在一個單獨的Windows控制檯應用程序,則記錄異常

使用的代碼登錄任何幫助,將不勝感激

感謝,

arunganu

....... 
using System.Diagnostics; 
using System.Data.SqlClient; 
using System.Data.SqlTypes; 
using Microsoft.SqlServer.Server; 
....... 
[Microsoft.SqlServer.Server.SqlProcedure] 
public static SqlInt32 Posting(SqlString tag) 
{ 
    try 
    { 
     ... 
     throw new ArgumentException("arg exc"); 
     ... 
     return 0; // success 
    } 
    catch (Exception e) 
    { 
     try 
     { 
      EventLog PostingLog = new EventLog("Application"); 
      PostingLog.Source = "Posting"; 
      PostingLog.WriteEntry(e.Message, EventLogEntryType.Error); 
      PostingLog.Close(); 
      return 1; // error 
     } 
     catch // in case when another exception is raised from the try block above 
     { 
      return 1; // error 
     } 
    } 
} 
+0

在代碼文本上使用代碼格式。像這樣它是不可讀的 – terjetyl 2008-12-17 17:07:05

回答

2

IIRC,你需要給大會不安全的權限。