从 .Net Frameworkf v.4.0 到 4.5 还发生了哪些其他无声变化? [英] What other silent changes did happen from .Net Frameworkf v.4.0 to 4.5?

查看:20
本文介绍了从 .Net Frameworkf v.4.0 到 4.5 还发生了哪些其他无声变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望切换到 .net 4.5,因为它提供了许多改进.

We want to switch to .net 4.5 cause it offers many improvements.

但是...有时我会发现一些棘手的细节,关于框架中的重大变化.

But...sometimes I found some tricky details about not trivial changes in the framework.

让我们以未观察到的 TPL 异常处理为例:

Lets look for TPL unobserved exception handling as an eample:

如果您不等待传播异常的任务,或访问它的 Exception 属性,异常根据任务被垃圾收集时的 .NET 异常策略.(注意,例外政策"一词没有链接或说明)

If you do not wait on a task that propagates an exception, or access its Exception property, the exception is escalated according to the .NET exception policy when the task is garbage-collected. (note, there is no link or clarification for the term "exception policy")

嗯,这似乎是 .Net v.4.0 中的行为

Well, that is seemingly the behavior as it was in .Net v.4.0

但是 Stephen Toub 告诉我们更多:

But Stephen Toub tells us more:

为了让开发者更容易地编写基于任务,.NET 4.5 更改了未观察到的默认异常行为例外.虽然未观察到的异常仍然会导致要引发 UnobservedTaskException 事件(不这样做将是一个中断更改),默认情况下进程不会崩溃.而是,异常最终会在事件引发后被吃掉,无论事件处理程序是否观察到异常.这个但是,可以配置行为.新的 CLR 配置标志可能用于恢复到 .NET 4 的崩溃行为.
请注意,此更改并不意味着开发人员应该粗心忽略未处理的异常……它只是意味着运行时多一点比以前更宽容了.

To make it easier for developers to write asynchronous code based on Tasks, .NET 4.5 changes the default exception behavior for unobserved exceptions. While unobserved exceptions will still cause the UnobservedTaskException event to be raised (not doing so would be a breaking change), the process will not crash by default. Rather, the exception will end up getting eaten after the event is raised, regardless of whether an event handler observes the exception. This behavior can be configured, though. A new CLR configuration flag may be used to revert back to the crashing behavior of .NET 4.
Note that this change doesn’t mean developers should be careless about ignoring unhandled exceptions… it just means the runtime is a bit more forgiving than it used to be.

这是一个很大的惊喜.考虑到文档没有更新.

That is a great surprise. Taking into account there is no update in documentation.

所以,我想知道我最好知道在 .Net v4.5 中发生的其他无声"变化
请分享您的知识.

So, I'd like to know what other "silent" changes I'd better know about happened in .Net v4.5
Please, share your knowledge.

附言这里的沉默"一词是指几乎从 Wat 的新文章 甚至官方文档.

P.S. Here word "silent" means the changes which hardly get known from Wat's New articles or even official documentation.

推荐答案

.NET Framework 重大变更文档 对此进行了说明(以及更多!).

The .NET Framework breaking change document calls this out (and more!).

这篇关于从 .Net Frameworkf v.4.0 到 4.5 还发生了哪些其他无声变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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