【发布时间】:2015-05-26 18:42:28
【问题描述】:
我有一个在 Windows 8.1 机器上使用为 .Net 4.0 编译的 Visual Studio Express 2008 开发的 .net 应用程序
它在 Windows 8.1 机器上运行良好,但在(非常)旧的单核 XP 机器上它偶尔会抛出 AccessViolationException,我不知道为什么。
在调试模式下在 Visual Studio 中运行,我没有得到任何帮助。
程序非常并行,我正在使用 TPL。
事件日志显示了这一点(这对我来说毫无意义):
Stack:
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr,
Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32,
System.Windows.Forms.ApplicationContext)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(System.String[])
我使用的标准 .net 之外的唯一库是 System.data.SQLite 和 Newtonsoft.JSON
应用程序正在使用 JSON 访问 RPC-Post API。
任何想法我的代码可能导致这种情况?就像我说的那样,它只发生在旧的 XP 机器上,但它可能是我只看到的竞争条件,因为它慢得多。我什至不知道从哪里开始!
【问题讨论】:
-
请贴一些代码 sn-p 以便人们查看和推荐
-
@hellowahab 我不能。正如我在问题中所说,我不知道是什么代码导致了错误。如果我可以发布代码 sn-p 我可以回答我自己的问题。我需要关于在哪里看的提示。我希望有人可以解码事件日志。
-
对我来说,您的问题似乎与 XP 上运行的任务并行库有关。
-
如果我不得不猜测,我会说处理程序中的某些内容没有正确同步并导致访问冲突。请注意,您会得到一个托管异常——即您处于 IL 级别。这很可能不是框架本身的错误。
-
是的,我就是这个意思。很多时候,这些异常来自尝试从后台线程与 ui 交互。你找过那个吗?
标签: .net multithreading task-parallel-library access-violation dispatch