CLR Stored Procedure Calling an Instance of a .NET Class

I checked the CLR stored procedure (listed below) The line of code where the exception is thrown was only added to target the exception logged in the EventLog I deployed the assembly and created a stored proc in the database However, when I execute the stored procedure, not a single entry not logged to Windows "EventLog

If code that uses EventLog in a standalone Windows console application, an exception is logged

Any help would be appreciated

Thank,

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

      

+1


source to share


1 answer


IIRC, you need to grant unsafe assembly permission.



+2


source







All Articles