- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我得到了一个有点复杂的 .net 控制台应用程序,它使用 WPF 作为一些通知窗口,也进行一些 http 调用。在极少数情况下,该应用程序会崩溃,而我能够获得的唯一错误消息来自 Windows 事件查看器:
Application: xyz.exe
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
at Microsoft.Win32.Win32Native.SetEvent(Microsoft.Win32.SafeHandles.SafeWaitHandle)
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()
我不知道堆栈跟踪来自哪里。任何想法在哪里寻找这个问题?以下是我的一些想法:
既然堆栈上有这个计时器的东西,它会不会与 System.Threading.Timer 有关?因为代码中用到了一些定时器?
还有一些使用超时的 HTTP 通信(httpclient、httpwebrequest)。是否与此错误有关?
很抱歉提出非常不具体的问题,但我完全被困在这里,只需要某种起点。
最佳答案
我遇到了同样的问题,发现是以下代码导致了异常:
using (ManualResetEvent resetEvent = new ManualResetEvent(false))
{
timer.Dispose(resetEvent);
resetEvent.WaitOne(1000);
}
如果计时器没有在一秒内被处理掉,则可能会发生异常。解决方案是 - 仅当 WaitOne 方法返回 true 时才处理 resetEvent。
关于c# - ObjectDisposedException - DangerousAddRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37386373/
Jeffry Richter 说(在 CLR via C# Edition 4, P.534)实现 IDisposable 的类中的所有方法和属性都应该抛出 ObjectDisposedExcepti
我收到以下错误: System.ObjectDisposedException: The ObjectContext instance has been disposed and can no lon
static void Main(string[] args) { Observable.Using(() => new EventLoopScheduler(), els => Observ
我正在使用 Entity Framework 6.x,一个实体看起来像这样(有些简化): public partial class Record { public int Id { get;
我需要在我的面板中添加一个Image,所以我使用以下代码: var image = new Image(); var source = new BitmapImage(); source.BeginI
由于windows phone不能处理gif,所以写了一点方法,但是好像有点错误。 下面的代码在运行到 (JPG 和 PNG 部分)bitimg.SetSource(e.Result) 时总是抛出异常
我在尝试创建用户时遇到错误。我在下面的代码中的 第 15 行 得到了它。 1 public async void AddOrganisationAdmin() 2 { 3 4
我得到了一个有点复杂的 .net 控制台应用程序,它使用 WPF 作为一些通知窗口,也进行一些 http 调用。在极少数情况下,该应用程序会崩溃,而我能够获得的唯一错误消息来自 Windows 事件查
我遇到了一个问题,其中大约有 50% 的时间抛出了 ObjectDisposedException。 try 中的代码(在 finally 中)导致了异常。我不确定如何处理。我可以吃掉异常,如下所示,
当实现 Dispose 模式时,对象的属性应该在对象被释放后抛出 ObjectDisposedException。 如果每个属性和方法在 setter 和 getter 的开头都有一行代码来抛出该异常
我发现有很多关于此问题的条目,但是没有解决方案对我有用。 简而言之,我有一个要在Docker中运行的.net Core 3.1控制台应用程序。如果我在Visual Studio中或通过命令行启动应用程
这是我的代码,不言自明。 using block 终止后 - output 变量被释放。为什么?我想从函数中返回它,处置 StreamWriter 但返回我的对象的正确方法是什么? public
我的应用程序通常在 10-20 个线程上运行,这些线程几乎每秒都会向 GUI 发送事件以更新某些控件。 当用户关闭这些应用程序中间时,与这些事件相关的所有更新都会导致几次随机崩溃。主要是 Object
下面两行代码一行一行执行: this.dataWriter.WriteBytes(message.MessageBuffer); await this.dataWriter.StoreAsync();
有没有办法验证一个 Session 是否已经被 NHibernate 处理掉了? 我在 Session 上有一个包装类,它有自己的 Finalizer 和 IDispoable 实现,但是如果在我自己
我有一个使用 Windows 身份验证和 Elmah 日志记录在 IIS 7 上运行的 MVC 应用程序。 通常当错误发生时,我们会调用类似“logger.LogError”的东西,它是一个包装器:
我有以下 EF 代码优先代码。它工作正常。但是当我查找“club2.Members”的值时,它显示如下: 'club2.Members' threw an exception of type 'Sys
你好,我正在编写一个 ASP.Net MVC 应用程序,我有一个专门用于数据库连接的特殊类。在我的 HomeController 中,我调用这个特殊 DB 类的静态方法,它将所需的数据返回到对象中。我
我有这个类,我经常(但不总是)在使用方法 ExecuteQuery 时得到 NullReferenceException 或 ObjectDisposedException: public class
我正在调试和增强 C#/XAML 程序,该程序在运行时反复生成异常,我可以在“输出”窗口中看到该异常。 System.dll 中发生类型为“System.ObjectDisposedException
我是一名优秀的程序员,十分优秀!