.NET 4, do you know the new features? - Top 10 Least Known Features

Submitted by Robert MacLean on Tue, 09/06/2011 - 12:20
More in this series can be found in the introduction.

image_thumb[2]We start off with the features that people just did not know about. I measured this on percentage, i.e. percentage of people who answered that they did not know about feature X.

The top 10 features in the dark are:

CLR/BCL: Microsoft.Win32.RegistryView

Percentage of People that Didn’t Know (PPDK): 90%

Introduction: On the 64-bit version of Windows, portions of the registry are stored separately for 32-bit and 64-bit applications. There is a 32-bit view for 32-bit applications and a 64-bit view for 64-bit applications.

Thoughts: If you just write to or read from the registry in your application you do not need to specify this. This means this feature is really only needed by people opening registry values for Windows or other applications, a very specific usage, so not surprised by this finding.

More detail: http://msdn.microsoft.com/en-us/library/microsoft.win32.registryview.aspx

CLR/BCL: Addition & Subtraction with IntPtr & UIntPtr

PPDK: 85%

Introduction: Adds an offset to the value of a pointer.

Thoughts: I can’t think of a scenario for the usage of this that most business application devs would care about – maybe it is useful doing interop or game dev. So not surprising it very unknown.

More detail: http://msdn.microsoft.com/en-us/library/system.intptr.op_addition.aspx

CLR/BCL: System.Device.Location

PPDK: 84%

Introduction: Allows you to talk to GPS sensors that Windows 7 supports.

Thoughts: Most Windows 7 machines, laptops, desktops etc… do not have a built in GPS yet so not surprising this isn’t well known. It is a pity since it is an awesome feature to include in applications and can work with a software GPS like GeoSense for Windows.

More detail: http://www.sadev.co.za/content/net-4-baby-steps-part-x-location-location-location

CLR/BCL: 64bit identification on Environment class

PPDK: 83%

Introduction: There is two new Boolean properties on System.Environment, one tells if the OS is 64bit and the if the process is 64bit.

Thoughts: Not sure why this isn’t better known – maybe people just don’t care about 64bit vs. 32bit or maybe people are not optimising for the operating system.

More detail: http://www.sadev.co.za/content/net-4-baby-steps-part-xiii-tiny-steps

CLR/BCL: Improved NGen sub-system

PPDK: 82%

Introduction: NGen is the sub-system or command line which compiles your assemblies from IL to machine code and can result in start up performance improvements.

Thoughts: This is a very specialised system and I have never seen anyone except Microsoft use it. So not surprised at all that people do not know of it.

More detail: http://blogs.msdn.com/b/clrcodegeneration/archive/2009/05/03/improvements-to-ngen-in-.net-framework-4.aspx

CLR/BCL: New options in Environment.SpecialFolder

PPDK: 80%

Introduction: This is used to help find the path to those special folders (think My Documents, which changes from profile to profile for example) and is used in conjunction with the GetFolderPath (see below).

Thoughts: There 25 new options, and some are just useless (Windows & Fonts for example: if you know the System drive they are ALWAYS <system drive>:\Windows & <system drive>:\Windows\Font respectively this is because Windows is has to be installed to a folder called Windows), but many others are very good and useful especially the x86 specific folders if you on a x64 OS & support for new Windows 7 features, like common folders.

So why it is so unknown is beyond me – this is GOOD STUFF!

More detail: http://www.sadev.co.za/content/net-4-baby-steps-part-xi-special-folders

CLR/BCL: ETW Support

PPDK: 80%

Introduction: ETW, Event Tracing for Windows, is a feature of Windows for doing logging at the kernel level. It is brilliant as you can do THOUSANDS of messages per second with VERY low CPU usage. With .NET 4 we have support for this in our applications and support to log information from the framework, like garbage collections.

Thoughts: Even though this is brilliant and powerful but logging is solved problem. So this really is only used or needed by people with some massive performance issues and I do not believe most developers are working on solutions at that scale.

More detail: http://naveensrinivasan.com/2010/03/17/using-clr-4-0-event-tracing-for-windows-etw-along-with-application-etw/

CLR/BCL: GetFolderPath improvements

PPDK: 80%

Introduction: GetFolderPath is used with Environment.SpecialFolder (above) and the improvements to create the folder and control verification if the folder is created.

Thoughts: The GetFolderPath additions are a new overload so if you were using it prior to .NET 4 it may look the exact same, so this could just be a discoverability issue.

More detail: http://www.sadev.co.za/content/net-4-baby-steps-part-xi-special-folders

CLR/BCL: MemoryCache

PPDK: 79%

Introduction: MemoryCache is a per process in memory cache for your application which is VERY easy to use regardless of application type. There is also some low plumbing that makes it possible to have the cache stored to other locations, like files or SQL.

Thoughts: WHAT THE HELL PEOPLE!? Don’t you people use caching?! I don’t get this at all, not even slightly. If you have an idea why this is so unknown, please share with me in the comment.

More detail: http://www.sadev.co.za/content/net-baby-steps-part-vii-caching

CLR/BCL: GUID Parsing Improvements

imagePPDK: 77%

Introduction: This is a way to parse a string in and have it converted to a GUID, regardless of the format of the GUID.

Thoughts: I just don’t think people need to do parsing of GUID’s that much and so it isn’t needed that much.

More detail: http://msdn.microsoft.com/en-us/library/system.guid.parse.aspx