windows - 如何理解 Windows 日志信息?
问题描述
我写了自动启动的ac#windows服务,它的工作主要是删除一些文本文件和修改父文件夹的最后写入时间。当这个程序第一次完成这项工作时,这个服务意外地停止了。我检查系统的日志记录,但我无法从日志记录信息中定位错误代码。所以我需要你的帮助!非常感谢!
这些是异常信息,异常发生在 .NET 运行时:
System.IO.IOException
at System.IO.__Error.WinIOError(Int32, System.String)
at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean)
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean)
at System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean)
at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean)
at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding)
at System.IO.File.InternalAppendAllText(System.String, System.String, System.Text.Encoding)
at WindowsService1.Service1+<>c__DisplayClass5_0.<Rec>b__0()
at System.Threading.Tasks.Task.Execute()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at WindowsService1.Service1+<Rec>d__5.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_1(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
上述异常20秒后,出现另一个错误显示错误模块路径为C:\Windows\system32\KERNELBASE.dll
解决方案
WindowsService1.Service1+<>c__DisplayClass5_0.b__0()
WindowsService1.Service1+d__5.MoveNext()
这两个堆栈条目实际上是您的应用程序的代码。顺便说一句,这就是为什么为项目指定非默认名称是一个好主意,如果您要命名它们,MyCompany.PreciousService
您会注意到它们不是来自运行时。
您可能还没有编写这些<>c__DisplayClass5_0
或d__5
嵌套类。C# 编译器做到了。这就是异步方法或 IEnumerable-returning 方法实现的幕后发生的事情yield return
理解转储的最简单方法——至少在调试版本中保持Service1.pdb
一致。Service1.exe
您需要同时构建它们,不能先构建 .exe 然后使用另一个构建中的 .pdb,不匹配。重现问题,您应该在堆栈跟踪中看到源文件名和行号。
推荐阅读
- c# - 正则表达式仅获取最后 32 个随机数字和数字
- plugins - MS Dynamics 365 Online Plugin External Rest API 访问给出错误
- python - 在 Jenkins 上使用 Alembic 时连续 SQL 语句之间的延迟
- mysql - 对不同列执行 SELECT WHERE 的表的最佳索引技术
- batch-file - 在使用 FFMPEG 将 MKV 转换为 MP3 时添加元数据
- python - 基本数学计算
- json - 如何使用 Apex 从嵌套 JSON 中读取值?
- mysql - NodeJS中的MySQL AES_DECRYPT,加密密钥的占位符?
- mysql-workbench - 通过 My SQL Workbench for Database (AWS RDS) 创建用户。收到“错误保存帐户” - 用户访问被拒绝(使用密码:是)
- python - 使用python从Cheat Engine获取地址处的数据