相关疑难解决方法(0)

找出方法可能在C#中抛出的异常

有没有办法找出.NET代码中的任何方法可能引发的异常?理想情况下,我想看看可能会抛出什么,并选择我想要处理的是什么.我想我想要从java中的throws子句获得的信息.

情况是我正在对来自网络的xml文档进行linq查询,并想知道可能出现的问题.我可以在反射器中打开组件并看一看,但我认为可能有一种更简单的方法.

.net c# exception

43
推荐指数
2
解决办法
1万
查看次数

如何捕获.NET应用程序中的所有异常/崩溃

可能重复:
.NET - 实现"捕获所有异常处理程序"的最佳方法是什么

我有一个崩溃的.NET控制台应用程序应用程序并向用户显示一条消息.我的所有代码都在一个try{<code>} catch(Exception e){<stuff>}块中,但偶尔会显示错误.

在Win32应用程序中,您可以通过安装各种异常处理程序捕获所有可能的异常/崩溃:

/* C++ exc handlers */
_set_se_translator
SetUnhandledExceptionFilter
_set_purecall_handler
set_terminate
set_unexpected
_set_invalid_parameter_handler
Run Code Online (Sandbox Code Playgroud)

什么是.NET世界中的等价物,所以我可以处理/记录/安静所有可能的错误情况?

.net c# exception-handling

39
推荐指数
5
解决办法
5万
查看次数

如何获取方法的MethodBase对象?

我正在尝试使用此帖子中找到的类,但它需要一个MethodBase才能运行.

我读了什么是获取MethodBase对象的最快方法?但我无法得到任何解决方案.

我需要做的是从函数中获取MethodBase对象.

例如,为Console类的静态函数WriteLine()获取MethodBase,或者为List <>的非静态函数Add()获取MethodBase.

谢谢你的帮助!

.net c# reflection methodbase

8
推荐指数
1
解决办法
5325
查看次数

如何找出方法可以抛出哪种异常?

我正在编写调用以下方法的代码 Windows.Networking.PushNotifications

// Summary:
//     Creates objects that you use to retrieve push notification channels from
//     the Windows Push Notification Services (WNS). These channels are bound to
//     an app or secondary tile.
[Threading(ThreadingModel.MTA)]
[Version(100794368)]
public static class PushNotificationChannelManager
{
    // Summary:
    //     Creates an object, bound to the calling app, through which you retrieve a
    //     push notification channel from Windows Push Notification Services (WNS).
    //
    // Returns:
    //     The object, bound to the calling app, that is …
Run Code Online (Sandbox Code Playgroud)

.net c# exception-handling exception

5
推荐指数
1
解决办法
171
查看次数