0

我使用 National Instruments LabWindows/CVI 开发了一个软件,并将 .exe 安装在具有 4GB RAM 的 Windows 7 32 位 PC 中。当我运行我的软件时,有时我会收到以下错误。

“某个程序导致程序停止正常工作。Windows 将关闭该程序并通知您是否有可用的解决方案”

这是非常随机的,有时这个错误永远不会出现。

谁能帮我理解这个问题。我已经多次查看我的软件代码,并且我确信我在软件中没有做任何导致此错误出现的错误。

这是否与 Windows 有关,我该如何解决?非常感谢您的帮助。

谢谢苏吉思·拉詹

4

2 回答 2

0

I have encountered similar problems several times.

This may happen even with simple programs like a console application used to get input from user and display some data on screen after processing it.

Usually, this is an indication that your computer is unable to provide enough resources to this program or that there is a bug in your code.

It might be random due to the following reasons:

  1. The Processor might already be busy with several demanding tasks and your program needs to be closed due to this. At other times, when it works well, the resources might be available.

  2. Your program might have a certain logical error that appears at runtime only when certain conditions are fulfilled. (such as an erroneous conditional statement)

  3. Your program might have an infinite loop.

  4. Windows suspects your file to be harmful to the system (for some reason).

于 2014-09-18T14:04:24.483 回答
0

有一些 youtube 视频告诉你去设置数据执行保护来解决。这是一条红鲱鱼。它也可能有害,特别是如果您运行旧的 dos 应用程序(因为出于某种原因您必须这样做)。

如果程序抛出任何类型的未处理异常,您将收到此错误消息。

如果您使用此代码段启动它...

 Dim psi As New ProcessStartInfo(pathToTarget)

 Dim p As Process = Process.Start(psi)
 Dim bIfinished As Boolean = p.WaitForExit(itimeout)
 If bIfinished = False Then
            p.Kill()
 End If
 iretVal = p.ExitCode

pathToTarget是目标 exe/bat (TARGET) 文件的完整路径

timeout是一个表示毫秒的整数。2 分钟将是 2*60*1000

如果程序自行结束,则bfinished为真。注意 - 这不是返回码。如果它未能在(本例中为 2 分钟)内完成,则 bFinished 将为假。

可以检查p.ExitCode以查看 TARGET 返回的内容。通常,0 表示成功,其他任何内容都是错误代码。

这是OP提到的消息框,(autoAging恰好是我用来演示的exe)。它还显示“XYZ 已停止工作”。谷歌需要知道这一点!

错误示例图片

请注意,代码将继续在您的应用程序中运行,因此您可以根据需要进行清理。单击或不单击“关闭程序”对我所知的 HOST 没有影响。

如果您拥有 TARGET 的代码,请确保您处理所有错误并返回适当的代码。这样您的呼叫应用程序 (HOST) 就可以知道如何做出反应。你也避免了这个消息框。

如果您不拥有 TARGET 的代码,您只需尽力而为。如果有一些输出您可以轻松检查,请执行此操作。否则我会假设失败并继续这个假设。
此消息框确实会消耗资源。虽然这不是一个大问题,但它们中的足够多会使你的盒子内存不足。

于 2016-10-31T14:43:33.750 回答