在Visual Studio外部运行时,应用程序已停止工作。 [英] Application has stopped working when running outside of visual studio.

查看:339
本文介绍了在Visual Studio外部运行时,应用程序已停止工作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有点奇怪的情况,想知道你是否能对它有所了解。

我编写了一个WPF应用程序作为数据导入程序。它使用MVVM方法并且运行得非常好。



在开发期间,我已经实现了try catch用于错误处理,可以捕获发生的错误,并将它们显示在活动日志中应用程序。



奇怪的是:



当应用程序在Visual Studio中运行时, try catch是捕获错误没有问题。读取错误消息并按照我的预期将它们显示给用户。

然而,当我编译程序并通过执行exe文件自己运行它时,错误(s) )发生,而不是很好地和干净地处理它我得到 ###已停止工作其中###是应用程序的名称。它试图寻找解决方案,但从未成功。



为什么我的尝试捕获不能在编译的exe中工作而不在visual studio中运行?





提前谢谢。

Hi Guys,

I have a bit of an odd scenario and was wondering if you could shed any light on it.
I've written a WPF application that works as a data importer. It uses the MVVM approach and works very nicely.

During development I have implemented try catch's for error handling which catch errors that occur and should display them into the activity log within the application.

The oddness is this:

When the application is running from within Visual Studio, the try catch's are catching errors with no problem. Reading the error message(s) and displaying them to the user as I would expect.
However, when I compile the program and run it on its own by executing the exe file, when the error(s) occur, instead of handling them nicely and cleanly I get a ### has stopped working where ### is the name of the application. It attempts to look for solutions but never succeeds.

Why would my try catches not be working in compiled exe when not run from within visual studio?


Thanks in advance.

推荐答案

这不是你现有的try / catch块是没有捕捉到新的错误。这是因为代码中没有导致新错误的try / catch块。代码中的某些内容正在假设在项目环境之外运行时不再有效。



我建议阅读this [ ^ ],作为该技术的另一个例子,this [ ^ ]。
It's not that your existing try/catch blocks are not catching the new error. It's the you don't have a try/catch block around the code that is causing the new error. Something in your code is making as assumption that is no longer valid when running outside of the project environment.

I would suggest reading this[^] and, as another example of the technique, this[^].


这篇关于在Visual Studio外部运行时,应用程序已停止工作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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