简体   繁体   English

执行过程中发生未处理的异常

[英]An unhandled exception occurred during the execution

I have handling the exception in my code as below, but still get error:我在我的代码中处理了如下异常,但仍然出现错误:

    catch (Exception e)
    {
       throw new Exception(e.Message);
    }

And here is the error:这是错误:

An unhandled exception occurred during the execution of the current web request.当前 web 请求执行期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

Exception Details: System.Exception: Object reference not set to an instance of an object.异常详细信息:System.Exception:Object 引用未设置为 object 的实例。

It sounds more like you are accessing a object that has been released/ or a null object.听起来您更像是在访问已发布的 object/或 null object。

IN the Catch block instead you use the following code to display an exception u r again throwing the Exception, remove it and try again.在 Catch 块中,您使用以下代码显示异常 u r 再次抛出异常,将其删除并重试。 Hope it helps.希望能帮助到你。

You still get an error because you are throwing a new exception in the catch block.你仍然会得到一个错误,因为你在 catch 块中抛出了一个新的异常。

From a catch block you are throwing a new excpetion which is creating a problem try to remove throw new exception or add a new parent try catch block从一个 catch 块中,您正在抛出一个新的异常,它正在创建一个问题尝试删除 throw new exception 或添加一个新的父 try catch 块

If you are handling your exception in this way (only retrowing it) than don't catch exeptions on this level.如果您以这种方式处理您的异常(仅追溯它),则不要在此级别上捕获异常。 Catch Exceptions in the method that's calling this function (Or where you want to handle your exception) and do your handling/showing the message overthere.在调用此 function (或您想要处理异常的地方)的方法中捕获异常并在那里处理/显示消息。

You probably don't have another try/catch block in the calling method which is causing the unhandled exception.您可能在调用方法中没有另一个导致未处理异常的 try/catch 块。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当前Web请求“Ненайденуказанныймодуль”的执行期间发生未处理的异常 - An unhandled exception occurred during the execution of the current web request, “Не найден указанный модуль” 当前Web请求执行期间发生未处理的异常 - An unhandled exception occurred during the execution of the current web request ','附近的语法不正确。 说明:执行期间发生未处理的异常 - Incorrect syntax near ','. Description: An unhandled exception occurred during the execution 执行当前 Web 请求期间发生未处理的异常。 ASP.NET - An unhandled exception occurred during the execution of the current web request. ASP.NET 如何修复“在执行当前 Web 请求期间发生未处理的异常。” - How to fix "An unhandled exception occurred during the execution of the current web request. " 当前Web请求的执行期间发生未处理的异常。 型号兼容性无法检查 - An unhandled exception occurred during the execution of the current web request. Model compatibility cannot be checked 在执行当前Web请求asp net的过程中生成了未处理的异常 - an unhandled exception was generated during the execution of the current web request asp net 当前Web请求执行期间生成了未处理的异常 - An unhandled exception was generated during the execution of the current web request 在执行当前Web请求期间生成了未处理的异常。[HttpAntiForgeryException] - An unhandled exception was generated during the execution of the current web request.[HttpAntiForgeryException] Sitecore MVC-在执行当前Web请求期间生成了未处理的异常 - Sitecore MVC - An unhandled exception was generated during the execution of the current web request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM