【问题标题】:Help with my application please! Can’t open image(s) with error: External component has thrown an exception…请帮助我的申请!无法打开图像并出现错误:外部组件已引发异常...
【发布时间】:2026-02-10 17:45:01
【问题描述】:

我相信我有一个用 C# 编写的应用程序,它将图像添加到 SQL Server 2005 数据库。它需要在我的计算机上安装 .NET 3.5。我安装了 .NET 3.5 并设置了一个数据库。它运行良好,但是一旦在一台计算机上运行时到达图像 100,它就会停止并给我这个错误:无法打开带有错误的图像:外部组件已引发异常....

当我在自己的计算机上运行该程序时,我可以访问 300 张图像,但在 300 张图像后它会停止,并显示无法打开图像并出现错误:外部组件已引发异常...。再次出错。

请帮忙!

这是一个堆栈:

有关调用的详细信息,请参阅此消息的末尾 即时 (JIT) 调试,而不是此对话框。

**************异常文本************** System.OutOfMemoryException:引发了“System.OutOfMemoryException”类型的异常。 在 System.String.GetStringForStringBuilder(字符串值,Int32 startIndex,Int32 长度,Int32 容量) 在 System.Text.StringBuilder..ctor(字符串值,Int32 startIndex,Int32 长度,Int32 容量) 在 System.Windows.Forms.Control.get_WindowText() 在 System.Windows.Forms.TextBoxBase.get_WindowText() 在 System.Windows.Forms.Control.set_CacheTextInternal(布尔值) 在 System.Windows.Forms.Control.PerformLayout(LayoutEventArgs 参数) 在 System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement 影响元素,字符串影响属性) 在 System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout,IArrangedElement elementCausingLayout,String 属性) 在 System.Windows.Forms.Control.OnResize(EventArgs e) 在 System.Windows.Forms.Control.OnSizeChanged (EventArgs e) 在 System.Windows.Forms.Control.UpdateBounds(Int32 x,Int32 y,Int32 宽度,Int32 高度,Int32 clientWidth,Int32 clientHeight) 在 System.Windows.Forms.Control.UpdateBounds() 在 System.Windows.Forms.Control.WndProc(消息和 m) 在 System.Windows.Forms.TextBoxBase.WndProc(消息和 m) 在 System.Windows.Forms.TextBox.WndProc(消息和 m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息和 m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** 加载的程序集 ************** mscorlib 程序集版本:2.0.0.0 Win32版本: 代码库:file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

【问题讨论】:

  • 基于您似乎没有代码并且仅“认为”应用程序是用 C# 编写的这一事实,我猜您没有编写它。获得修复的唯一方法是联系程序的作者。

标签: c# .net sql


【解决方案1】:

你有更多关于抛出异常时的堆栈跟踪信息吗?根据您的描述,听起来资源没有被关闭或正确处置,最终资源耗尽。

编辑:在看到您的堆栈跟踪后,它证实了我的怀疑,即资源没有得到正确处理,并且它运行的系统内存不足。正如 cmets 中所建议的,您应该联系程序的构建者并建议他们使用分析器对其进行调试并正确处理对象,或者让它们超出范围以便垃圾收集器可以处理它们。此外,您可能会建议,如果在加载文件时发生错误,则他们使用缓冲区通过流加载文件,而不是一次将整个文件加载到内存中,然后在不再需要后释放它。

【讨论】:

    最近更新 更多