Async Await targeting 4.0 deployment requirements

耗尽温柔 提交于 2019-12-21 05:26:08

问题


Microsoft has updated the async/await targeting for .net 4.0 and now suggests using the Microsoft.Bcl.Async library available on nuget.

In the release notes, it states that .net 4 with KB 2468871 is required.

  1. Is KB2468871 a build requirement or a deployment requirement?
  2. What aspect of KB2468871 makes it required?

回答1:


Quoting from http://support.microsoft.com/kb/2468871/en-us

Feature 5 Changes to the support portable libraries. These changes include API updates and binder modifications. This update enables the CLR to bind successfully to portable libraries so that a single DLL can run on the .NET Framework 4, on Silverlight, on Xbox, or on the Windows Phone. This update adds public Silverlight APIs to the .NET Framework 4 in the same location. The API signatures will remain consistent across the platform. All modifications are 100 percent compatible and will not break any existing code.

It turns out that without this kb installed Microsoft.Bcl crashes (it tries to bind to silverlight System.Core library which is not on the system)




回答2:


The only safe way to use async/await in .net 4.0 supporting xp users without installing KB2468871 is installing async CTP v3 in vs 2010 SP1, nuget microsoft bcl async and implementing own AsyncTaskMethodBuilder and AsyncVoidMethodBuilder. (and remove async ctp dll reference)

It is the only way any non async CTP async implementation in .net4, vs 2010, without installing vs 2012, net 4.5 or KB2468871 WILL WORK.

Any other ready to use implementation of async on .net4 out there uses the new way of implementing and bridging async code within the compiling process, that's why you need to install async CTP, it is the only async implementation for .net4, modifying the csc compiler to support it.

Microsoft has changed the types compiler use in c#5 and .net 4.5 to generate async code, basically they could it done easily for .net4, but instead they choose to force anyone to install vs 2012 and .net 4.5, something that is unacceptable for companies that need to support xp users, because you will have no way to see and fix any .net 4 bugs that was fixed in .net 4.5.

Microsoft.Bcl.Async, AsyncTargetingPack, AsyncBridge they all WON'T WORK without .net 4.5 installed or KB2468871 for .net 4.0.

They WILL ALL WORK if you implement AsyncTaskMethodBuilder and AsyncVoidMethodBuilder on your own, you can even copy/paste it's implementation from async ctp v3 with minor changes and it will just work.

So if you really concerned by the deployment requirement and other things related to supporting xp users, I would strongly advise to do is I described.




回答3:


The release notes detail:

when targeting any of the following platforms (or higher versions):

• .NET Framework 4.0 (with KB2468871)

So, that means you're 'targeting' 4.0 w/KB2468871 as in KB2468871 must deployed on the target computer for the library to be supported.

There is no detail about what parts of KB2468871 are required for Microsoft.Bcl.Async. I suggest you contact the BCL team, post to the blog, or contact the Nuget package owners for more details. I'm unclear what knowing which parts of the KB are required would make a difference...




回答4:


It is possible to use AsyncBridge portable without KB2468871 to get async/await functionality. https://www.nuget.org/packages/AsyncBridge.Portable/



来源:https://stackoverflow.com/questions/15440829/async-await-targeting-4-0-deployment-requirements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!