相关疑难解决方法(0)

在Visual Studio 2010中进行调试时,忽略跨越AppDomains的异常

我在调试调用另一个AppDomain的应用程序时遇到问题,因为如果在其他AppDomain正在执行的任何操作中发生异常,则异常会冒泡并导致Visual Studio 2010无论如何都会中断.

我正确地包装了抛出a的方法调用try/catch,并且当我正常运行应用程序(ASP.NET MVC应用程序)时正常捕获异常,但是w3wp.exe在Visual Studio 2010中调试时,它总是在方法上中断调用那个抛出,即使应该被抓住,我也无法通过异常.

我试图装饰外部方法,其中try/catch和throw方法调用完成,[DebuggerStepThrough]但绝对没有效果.执行"继续(F5)","跳过(F10)"或"跳出(F11)"也不执行任何操作; Visual Studio只是暂停了一下,然后在相同的位置再次中断,但具有完全相同的异常.一旦Visual Studio在发生异常的位置停止,似乎绝对没有办法继续前进.

我正在做的就是调用assembly.GetExportedTypes()如果导出的类型引用了一个无法找到的程序集(我想忽略的情况),可能会抛出.抛出的异常是:

FileNotFoundException越过了本机/托管边界

我正在抓住FileNotFoundException,正如我所说的,这在运行应用程序时有效,但在调试时无效.如何让调试器理解我assembly.GetExportedTypes()抛出一个老鼠屁股?

更新:

我认为通过取消选中Visual Studio 2010中的选项"在异常时跨越AppDomain或托管/本地边界(仅限托管)"(在"调试">"常规"下)中的选项来解决此问题,但此问题刚刚再次出现.我已经撒了[DebuggerStepThrough],[DebuggerStepperBoundary]并且[DebuggerNonUserCodeAttribute]对所讨论的方法没有任何影响.

c# debugging exception appdomain

11
推荐指数
1
解决办法
4675
查看次数

eventhandler抛出的WPF异常被吞了?

当我在事件处理程序中抛出异常时,异常处理程序没有被调用?

从以下开始的精简示例的示例代码:

应用程序.xaml

<Application x:Class="WpfApplication1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml"
             DispatcherUnhandledException="App_DispatcherUnhandledException" >
    <Application.Resources/>
</Application>
Run Code Online (Sandbox Code Playgroud)

应用程序.xaml.cs

using System.Windows;
using System.Windows.Threading;

namespace WpfApplication1
{
    public partial class App : Application
    {
        //This method is called when ButtonA is clicked, but not when ButtonB is
        //clicked (and a (random) file is selected ofcourse).
        void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message, "An exception occurred", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

主窗口.xaml

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Button Content="Button A" HorizontalAlignment="Left" Margin="10,10,0,0" …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf xaml exception-handling

4
推荐指数
1
解决办法
3215
查看次数

标签 统计

c# ×2

.net ×1

appdomain ×1

debugging ×1

exception ×1

exception-handling ×1

wpf ×1

xaml ×1