当前位置:网站首页 > 技术博客 > 正文

c中clr是什么意思



 1 using System;  2 using System.Diagnostics;  3 using System.Globalization;  4 using System.IO;  5 using System.Runtime.InteropServices;  6 using System.Text;  7 using System.Threading;  8 using System.Web;  9 10 namespace WebMonitor { 11 public class UnhandledExceptionModule: IHttpModule { 12 13 static int _unhandledExceptionCount = 0; 14 15 static string _sourceName = null; 16 static object _initLock = new object(); 17 static bool _initialized = false; 18 19 public void Init(HttpApplication app) { 20 21 // Do this one time for each AppDomain. 22 if (!_initialized) { 23 lock (_initLock) { 24 if (!_initialized) { 25 string webenginePath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "webengine.dll"); 26 27 if (!File.Exists(webenginePath)) { 28 throw new Exception(String.Format(CultureInfo.InvariantCulture, 29 "Failed to locate webengine.dll at '{0}'. This module requires .NET Framework 2.0.", 30  webenginePath)); 31  } 32 33 FileVersionInfo ver = FileVersionInfo.GetVersionInfo(webenginePath); 34 _sourceName = string.Format(CultureInfo.InvariantCulture, "ASP.NET {0}.{1}.{2}.0", 35  ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart); 36 37 if (!EventLog.SourceExists(_sourceName)) { 38 throw new Exception(String.Format(CultureInfo.InvariantCulture, 39 "There is no EventLog source named '{0}'. This module requires .NET Framework 2.0.", 40  _sourceName)); 41  } 42 43 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException); 44 45 _initialized = true; 46  } 47  } 48  } 49  } 50 51 public void Dispose() { 52  } 53 54 void OnUnhandledException(object o, UnhandledExceptionEventArgs e) { 55 // Let this occur one time for each AppDomain. 56 if (Interlocked.Exchange(ref _unhandledExceptionCount, 1) != 0) 57 return; 58 59 StringBuilder message = new StringBuilder("/r/n/r/nUnhandledException logged by UnhandledExceptionModule.dll:/r/n/r/nappId="); 60 61 string appId = (string) AppDomain.CurrentDomain.GetData(".appId"); 62 if (appId != null) { 63  message.Append(appId); 64  } 65 66 Exception currentException = null; 67 for (currentException = (Exception)e.ExceptionObject; currentException != null; currentException = currentException.InnerException) { 68 message.AppendFormat("/r/n/r/ntype={0}/r/n/r/nmessage={1}/r/n/r/nstack=/r/n{2}/r/n/r/n", 69  currentException.GetType().FullName, 70  currentException.Message, 71  currentException.StackTrace); 72  } 73 74 EventLog Log = new EventLog(); 75 Log.Source = _sourceName; 76  Log.WriteEntry(message.ToString(), EventLogEntryType.Error); 77  } 78  } 79 }

版权声明


相关文章:

  • linux发行版本有哪些?2024-12-06 20:29:59
  • pwn rop入门2024-12-06 20:29:59
  • vb二级证书有用吗2024-12-06 20:29:59
  • python里jieba库怎么用2024-12-06 20:29:59
  • yml格式怎么打开2024-12-06 20:29:59
  • 分词器有哪些2024-12-06 20:29:59
  • 函数已有主体是什么意思2024-12-06 20:29:59
  • java程序设计之网络编程2024-12-06 20:29:59
  • c解析json数据的代码2024-12-06 20:29:59
  • sqlserver触发器实例2024-12-06 20:29:59