在IOCompletionCallback中获取AccessViolationException [英] getting AccessViolationException in IOCompletionCallback

查看:339
本文介绍了在IOCompletionCallback中获取AccessViolationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序启动时出现以下异常:

I get the following exception on application startup:

System.AccessViolationException
   at System.Threading.Overlapped.get_iocbHelper()
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

这就是整个调用堆栈.在应用程序启动时,只有十分之一的运行时间发生.我确实在我的套接字代码中使用了IOCompletion.我认为这与此有关.但是,为什么在我呼叫Socket.ReceiveFromAsync时不显示此异常?我有很多同时调用ReceiveFromAsync的套接字,但是我没有在同一套接字上同时调用两次.关于原因有什么想法吗?

That's the entire call stack. It only happens one in twenty runs right on application startup. I do use IOCompletion in my socket code. I assume it is related to that. However, why would this exception not show when I call Socket.ReceiveFromAsync? I have a lot of sockets that simultaneously call ReceiveFromAsync, but I don't call it twice on the same socket concurrently. Any ideas on the cause?

推荐答案

在尽力使IO完成方法起作用之后,我最终放弃了,只写了自己的线程来调用send和receive的同步版本.从那以后我没有任何问题.

After trying really hard to get the IO-completion method to work, I finally gave up and just wrote my own threads that call the synchronous versions of send and receive. I haven't had any problems since.

我有一些使用IO补全的C ++代码,即使是在大容量设置下,我也从来没有遇到过这个问题.

I have some C++ code that uses IO-completion, in a high-volume setting even, and I've never had this problem.

因此,在我看来,IO完成的C#实现存在错误,并且它不是反恶意软件,防火墙或任何(非Microsoft)垃圾软件.

So it seems clear to me that the C# implementation of IO-completion is bugged, and that it's not anti-malware, firewall, or any (non-Microsoft) crapware.

这篇关于在IOCompletionCallback中获取AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆