Cluj München 1140km

Gânduri clujene din Bavaria

München - Munich - Monaco di Baviera

5. februarie 2014 13:15
by skorpionking
1 Comentarii

Microsoft .NET Framework 4.5.1 - New features making development more productive

5. februarie 2014 13:15 by skorpionking | 1 Comentarii

Async Debugging Improvements After setting up a solid and easy-to-use base for the asynchronous programming model in the previous Framework releases, Microsoft wanted to smooth out some remaining aspects for the overall developer experience with the .NET Framework 4.5.1. Two questions are essential for debugging asynchronous code: “How did I get into this async method?” and “What is the state of all the tasks in my application?” Visual Studio 2013 introduces enhancements to the Call Stack and Tasks windows to help you find answers to these questions in a much more intuitive way. These improvements are supported for desktop, Web and Windows Store apps on Windows 8.1 and are available for C++ and JavaScript as well.

It’s common to have nested async method calls within an app or library, which rely on the await keyword to manage the flow of execution. Previously, Visual Studio didn’t show the chain of async calls when stopped at a breakpoint within a Task. Visual Studio 2013 provides a logical and sequential view of methods in a nested chain of calls for both asynchronous and synchronous methods. This makes it easier to understand how the program reached a location inside an asynchronous call.

First screenshot shows an asynchronous code sample. The next two demonstrate the difference between the call stack views of Visual Studio 2012 and Visual Studio 2013 for that code. More details of this feature can be found in the “Debugging Asynchronous Code in Visual Studio 2013—Call Stack enhancements” blog post at

The Tasks window in Visual Studio 2013 is designed to help you understand the state of async tasks in your apps by displaying all the currently running and scheduled tasks. It’s a replacement for the Parallel Tasks window that was available in previous Visual Studio versions. The next figure shows a snapshot of a Visual Studio 2013 Tasks window for the sample code given above:

x64 Edit and Continue This was a popular debugger feature request, with more than 2,600 votes on the Visual Studio UserVoice site where users can request new features ( Developers have loved using the Edit and Continue feature since it was intro­duced with Visual Studio 2005 and the .NET Framework 2.0 release, for x86 projects. Edit and Continue makes it easier to write the correct code by letting you change the source code during a debugging session, while app state is available. You can even move the instruction pointer so you can replay code after making a change. It provides a more productive development experience because you don’t have to stop and restart the session to validate your changes.

x64 support for Edit and Continue is now enabled with Visual Studio 2013 and the .NET Framework 4.5.1 release. You can use this feature for debugging desktop applications (Windows Presentation Foundation, Windows Forms and so on), Windows Store apps, ASP.NET Web applications and Windows Azure Cloud Services projects targeting x64, AnyCPU or x86 architectures.

Managed Return Value Inspection Debugger support for managed return values is another popular request with more than 1,000 votes on the UserVoice site. The Visual C++ debugger has an existing feature that allows you to observe the return values of methods, and Microsoft wanted the same capability for .NET as well. This feature is useful for many code patterns. However, you can really see its value with nested methods, as demonstrated in the figure below. With this feature, you no longer have to worry about storing the results of your methods in locals solely to make debugging easier. When you step over a method call, both direct return values and the return values of the embedded methods will be displayed in the Autos window along with the parameter values passed to the functions. You can also use the Immediate window to access the last return value through the use of the new $ReturnValue pseudo-variable.

Windows Store Development Enhancements Microsoft responded to feedback and provided .NET support for new Windows Runtime (WinRT) features to improve the .NET Windows Store app development experience.

One of the pain points was converting a .NET Stream to a WinRT IRandomAccessStream. In the .NET Framework 4.5.1, VS2013 added a new extension method, AsRandomAccessStream, for System.IO.Stream to solve this problem. You can now write the following code, which allows you to easily provide an IRandomAccessStream:

This example code reads an image from the Web and displays it in a XAML Image control (represented by the “image” variable).

Another improvement is error propagation in the Windows Runtime. The Windows Runtime, in Windows 8.1, enables exceptions to pass between WinRT components. With this support, an exception can be thrown from a C++ WinRT component and be caught in C# (or vice versa). Additional information for the exception is now available via the Message and StackTrace properties on System.Exception.

The Windows Runtime also added support for nullable value types in structures. You can build managed WinRT components that expose structs with this new feature, such as in this sample code:

Enjoy programming in the new VS2013 with the Update 1 and .NET Framework 4.5.1! More can be found  here(.NET Team Blog)

Comentarii (1) -

Hollis Stroupe

How do i place the blog comment approval upon my facebook or myspace to agree to blog comments before posting them?

Adaugă comentariu