C#postsharp例外hanlder [英] C# postsharp exception hanlder

查看:189
本文介绍了C#postsharp例外hanlder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究重编码的c#项目,现在我正在尝试处理项目中发生的所有异常。

我可以创建OnExceptionAspect并将其添加到我的代码?



[可序列化]

类ExceptionAspect:OnExceptionAspect

{

public override void OnException(MethodExecutionArgs args)

{

Console.WriteLine(String.Format(Exception in:[{0}],Message:[{1}} ],args.Method,args.Exception.Message));

args.FlowBehavior = FlowBehavior.Continue;



base.OnException (args);

}

}



我尝试了什么:



i尝试但是当发生错误时程序崩溃并退出

hi , i have been working on a heavy coded lines c# project and now i'm trying to handle all the exceptions occurs in the project .
can i make a OnExceptionAspect and just add it to my codes ?

[Serializable]
class ExceptionAspect : OnExceptionAspect
{
public override void OnException(MethodExecutionArgs args)
{
Console.WriteLine(String.Format("Exception in :[{0}] ,Message:[{1}]", args.Method, args.Exception.Message));
args.FlowBehavior = FlowBehavior.Continue;

base.OnException(args);
}
}

What I have tried:

i tried but when an error occured the program just crashed and exit

推荐答案

异常处理:你有没有研究过这个:[ ^ ]?



如果您已获得PostSharp许可并拥有有效许可证,那么利用他们出色的直接支持:[ ^ ]



或者,使用StackOverflow中非常活跃的PostSharp组提问:[ ^ ]。



如果您使用的是免费的Essentials版本或试用版,那么请确保您正在尝试使用该版本允许: [ ^ ]



Exception Handling: have you studied this: [^] ?

If you have licensed PostSharp, and have an active license, then take advantage of their excellent direct support: [^]

Or, use the very active PostSharp group in StackOverflow to ask questions: [^].

If you are using the free Essentials edition, or a trial version, then make sure what you are trying is allowed with that version: [^]

Quote:

是的。您可以使用PostSharp Essentials构建商业产品并重新分发它们。 Express Edition包含PostSharp Ultimate的所有功能,但是,您可以应用方面的类型数量限制为每个项目10个或每个解决方案50个。

Yes. You can build commercial products using PostSharp Essentials and redistribute them. Express Edition contains all the features of PostSharp Ultimate, however, the number of types to which you can apply aspects is limited to 10 per project or 50 per solution.


这篇关于C#postsharp例外hanlder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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