Skip to main content
Anything related to the .NET framework

.NET 4, do you know the new features? - The 12 features the majority thinks are useless.

image

More in this series can be found in the introduction.

Another interesting statistic was that only 12 of the 61 features are rated useless, in other words more people thought those features were useless than useful.

This is really good, because this really means that about 80% of the new features are seen to be useful and thus that was a good spend of resources for Microsoft.

I am measuring this in a Useful Ratio – Number of people who think it is useful compared to number of people who think it is useless. For examples:

  • 1 : 1 – For every one person who thinks it is useful, one person thinks it is useless
  • 2 : 1 – Two people think it is useful for everyone that thinks it isn’t.
  • 0.5 : 1 – Half a person thinks a feature is useful compared for everyone who thinks it is useless.

CLR/BCL: Addition & Subtraction with IntPtr & UIntPtr

Useful Ratio: 0.3 : 1

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

Thoughts: The first feature to appear on more than one list, as it also appeared on the top 10 least known. So this brings up an interesting though – you either don’t know of this or you think it is shit. My views of why this is useless is the same as why it is unknown, the use case for this is TINY!

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

CLR/BCL: Complex Number Support

Useful Ratio: 0.3 : 1

Introduction: Complex numbers are a specific mathematical concept especially for doing graphs, vector calculus and other things that are pretty specialised.

Thoughts: .NET 4 also included another new construct called Tuple and .NET has had KeyValuePair for ages and this seems very similar to those (from the perspective of someone without university math). All it gives compared to the other two are some easier math functions. So easy to see why it is not that useful as it is easy to implement those on Tuple or KeyValuePair.

More Info: http://www.sadev.co.za/content/net-4-baby-steps-part-xii-numbers

WPF: Touch Support

Useful Ratio: 0.4 : 1

Introduction: WPF now supports input from touch, like you can touch buttons and text boxes etc…

Thoughts: This feels very similar to System.Device.Location which is hampered by the lack of hardware that supports the feature.  WPF is doubly hurt because Silverlight is competing with it and has touch support already.

More Info: http://blogs.msdn.com/b/jaimer/archive/2009/11/04/introduction-to-wpf-4-multitouch.aspx

CLR/BCL: Side by Side (SxS) CLR's in the same process

Useful Ratio: 0.6 : 1

Introduction: Prior to .NET 4 you could not allow two different CLRs (i.e: 1.0, 1.1 or 2.0) in exist in the same process.

Thoughts: I hit this a few times with ASP.NET where two sites ran in the same AppPool and one site was running 1.1 and the other 2.0 and there would be a failure.

This was primarily put in also to allow plug-ins built in different CLR’s run in the same application.

Besides the ASP.NET issue I’ve not seen a need for this, it really feels like plumbing for future applications.

Update: Mike posted in the comments a great use case I didn't think of, which adds more value for this feature.

More Info: http://msdn.microsoft.com/en-us/magazine/ee819091.aspx

WPF: Text Rendering Stack

Useful Ratio: 0.6 : 1

Introduction: WPF previously rendered text differently to how Windows did, this is where the perception of it being blurry comes from. As part of Visual Studio 2010 they used WPF and spent considerable time improving the text rendering.

Thoughts: I don’t get this, it means that WPF is better looking and it costs nothing for you. Maybe the issue is because it costs nothing people see the value as nothing?

More Info: http://www.hanselman.com/blog/WPFAndTextBlurrinessNowWithCompleteClarity.aspx

ASP.NET: CDN Support

Useful Ratio: 0.7 : 1

Introduction: Microsoft has a large content delivery network which contains many scripts that web sites use, like jQuery. Using a CDN can significantly improve performance of your website.

Thoughts: Reasons why I think people don’t like this:

  • Internal only applications cannot benefit from this.
  • People prefer other CDN’s – as there are a few BIG ones now.
  • People don’t trust a CDN

If you can use this this, you should, it is a simple switch to turn it on.

More Info: http://www.asp.net/ajaxlibrary/cdn.ashx

CLR/BCL: ETW Support

Useful Ratio: 0.8 : 1

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 CLR support for this so understanding what is happening in the CLR along with our applications becomes very easy.

Thoughts: We have been able to write to ETW since .NET 3.0 – all this is is support for the CLR events, so really you need to be debugging performance issues in the CLR.

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

ASP.NET: Grid & List Row Selection Persistence

Useful Ratio: 0.8 : 1

Introduction: Allows the selected row in a list or grid to be persisted automatically over post backs.

Thoughts: Simple for why this is not seen as useful: People who care use ASP.NET MVC

More Info: http://www.asp.net/aspnet-4/videos/aspnet-4-quick-hit-persistent-gridview-row-selection

CLR/BCL: Primary Interop Assembly Embedding

Useful Ratio: 0.9 : 1

Introduction: PIA’s (Primary Interop Assemblies) are mappings between COM+ API’s and .NET. Similar to header files in C. These are exposed as separate assemblies and in .NET 4 you can embed just the code you use in your assembly as part of the build rather than requiring the separate assemblies.

Thoughts: I don’t think this is important at all – we have learnt to include the assemblies we need with our solution so embedding code is just a solution to a problem that didn’t exist.

More Info: http://www.hanselman.com/blog/CLRAndDLRAndBCLOhMyWhirlwindTourAroundNET4AndVisualStudio2010Beta1.aspx

CLR/BCL: SortedSet

Useful Ratio: 0.9 : 1

Introduction: SortedSet is a class for doing sorting, similar to SortedList or SortedDictionary. However where the old ones internally use a hash table, this uses a binary tree and thus gets some FANTASIC performance in many situations where the others would have bad perf.

Thoughts: I don’t think there is enough understanding of patterns with .NET developers – we are too quick to just use what Microsoft gives us and move along. So there isn’t enough people thinking about the pattern for their data structures so they see this as a solution to a solved problem. Those that do care, already have built their own code for this problem.

More Info: http://www.sadev.co.za/content/net-4-baby-steps-part-vi-sortedset

WPF: Windows 7 Integration (System.Windows.Shell)

Useful Ratio: 0.9 : 1

Introduction: Building a WPF application and want to take advantage of new Windows 7 features like the taskbar, quick launch or overlays? It is easy with the System.Windows.Shell.

Thoughts: I don’t get why this isn’t more popular, it is a VERY useful set of tools. Maybe people just don’t like WPF?

More Info: Rudi Grobler has a series on this:

ASP.NET: Routing for WebForms

Useful Ratio: 0.9 : 1

Introduction: ASP.NET MVC brought us routing support so that we can direct URL’s to specific content based on a convention or a configuration. With .NET 4 we get support for this in WebForms.

Thoughts: WebForm developers don’t care about this, they have never needed it and don’t need it now. I see the big market for this is actually hybrid scenarios where you using WebForms and MVC in the same system… a VERY small market.

More Info: http://msdn.microsoft.com/en-us/magazine/dd347546.aspx

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

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

.NET 4, do you know the new features? - Introduction

imageAs part of my work ahead of Microsoft Tech·Ed Africa 2011 I did a online, anonymous poll to see how well known are the new features in .NET 4, and over the next few days I thought I would share my findings.

The poll asked you to state for feature X: Do you know it? And if you do know it, is it a useful feature?

I listed 61 features that are new in .NET 4 – which pretty much covered the length and breadth of it. There is some consolidation, like ALL of Workflow is one item but WF4 is a rewrite so pretty much is one BIG new feature and some other aspects of consolidation.

I suspected a fairly high rate of known features because .NET 4 was released 16 months ago (12 April 2010) and it has been demo’d and talked about a lot - even I have done a talks on the new features. However the ratio of unknown to known is 1.2 : 1 – so while there is a close parity, there are more are unknown than known, which surprised me a bit.

I have broken up talking about the results into a series, because I want to talk about each feature briefly so a single post would have been MASSIVE.

Below are links to the other parts of the series:

Finally I want to say a BIG thanks to everyone who answered and those who shared links on social networks and with friends!

The raw data can be found below.

Lightswitch is on SALE!

Nurt img1Very different from my normal ramblings but I thought worth a quick post, Microsoft has Lightswitch on sale at the moment for 33% off the price! This is a world wide offer so you can get it via your distributors, LARS or from the Microsoft Online Store.

So if you are looking to get started in Lightswitch, NOW IS THE TIME!

OLE DB is dead, long live ODBC

imageMicrosoft has announced that OLE DB with regards to SQL Server has entered the end of it's life - it has about 7 or 8 years left and "Denali", the next version of SQL Server, will be the last version to support it. The recommendation is to use ODBC going forward.

The reasoning is pretty sound to me:

  1. Better cross platform support - yip Microsoft cares about cross platform.
  2. Better clound support - No surprise that Microsoft cares about the cloud.
  3. I am also assuming that budget is part of this, providing OLE DB & ODBC is two dev teams, two test suites etc… Just doesn’t make sense. Rather consolidate and spend the savings elsewhere.

It is important to note that other OLE DB providers and OLE DB itself are still continuing, we are just talking about SQL Server.

Have a look at the picture to the right only two out of the seven are affected by this announcement, that means there is still a big investment in it and I doubt we we will see OLE DB going away completely anytime soon.

Microsoft has produced a helpful guide to migrating which you can get below.

Nugget: String concatenation compiler optimisation

William Brander responded to my last nugget on compiler optimisation with a tweet about another one:

image

So what does that look like? Let’s look at the code we type:

string interesting = "first";
interesting += " second";
interesting += " third" + " forth";
interesting = interesting + " fifth";
interesting = interesting + " sixth" + " seventh";
Console.WriteLine(interesting);

And this optimises the concatenation to a single line and drops the variable. Interesting use of braces for fifth & sixth though, when I switched += to =.

 

Console.WriteLine(("first" + " second" + " third forth") + " fifth" + " sixth seventh");

Windows Phone 7: Professional Tips - Always show the SystemTray

imageIn Windows Phone 7 there is an option to show a little strip at the top of your application which shows time, battery and signal strength. This is called the SystemTray.

My suggestion for a professional applications, is that you should be showing that SystemTray. Full screen games & media viewing excluded, but most tool like applications should be showing it.

My reasoning is two fold:

  1. If you user is spending any time in your application they may need to check their battery or  they will need to check the time. Having it available keeps them in your application and keeps them from being frustrated by the toggling backwards and forwards (glance and go!).
  2. If you application connects to the internet, and you fail to connect you are required to tell the user that it failed. For me internet connection failures are often due to signal or due to being connected to a hotspot. If it fails and I do not have a SystemTray, then I need to leave the application to check those details. Once again, the glance and go principal!

It takes up a few pixel’s but your users will be happier for it being there!

App.Config Transformations: The community shines where Microsoft drops the ball

Last year May, I spoke at DevDays Durban about what is new in ASP.NET 4? One of the highlights of that talk is a feature called Web.Config transforms. In short you have a base web.config and then a file per compiler target (i.e. RELEASE, DEBUG). These extra files contain rules on how to transform your web.config when it is published.

In a way of an example you have might your web.config to use your local SQL Server when in Visual Studio, but when you publish a DEBUG build to testing it changes the config to use the test SQL Server. Or when you publish to production it turns off a bunch of logging and shows friendly error messages.

image

There is TWO caveats in this process:

  1. ONLY works for ASP.NET* projects as this is something the ASP.NET team built into their publishing tool support.
  2. ONLY works for publish, if you have an ASP.NET* project and hit F5, nothing happens Sad smile

*ASP.NET = ASP.NET Core, and thus systems that build on top of it (WebForms, MVC & WebPages) all get it.

This is something we need in EVERY project type and we need with F5. Thankfully some bright people did just that for us, with the VS add-in Slow Cheetah.

So now you get the full experience on any project type, PLUS you get a brilliant feature missing in the ASP.NET one – PREVIEW. You can see what the resulting config will look like!

Windows Phone 7: Professional Tips - Drop the splash screen

The guidelines for WP7 state your application must start within 3 seconds – so many applications include a splash screen to show the user while the rest of the application loads. The splash screen is included by default so you may think you MUST to include it (I did think this too), but the truth is you don’t need to.

If you can (i.e. your application loads under 3 seconds) then you should drop it as it will allow your application to start quicker (about 2 seconds faster in fact), this means your users can get into your application quicker and that will make them happier!

Windows Phone 7: Professional Tips - Storing your settings

In Windows Phone 7 there are two ways to store values State & IsolatedStorageSettings which have their various pro’s and con’s. I prefer to use the IsolatedStorageSettings for most scenarios but this tip will apply to both, so when you see the code referring to one it will work on both.

Very simply the first setting you should store is one called version (or similar) and should have a version indicator. In short it tells you what version of the settings you are working with!

IsolatedStorageSettings.ApplicationSettings["version"] = "1";

Having this field has two advantages for you, first it gives you a very simple way to check if you have settings available & if it is not, then your app is running for the first time.:

if (IsolatedStorageSettings.ApplicationSettings.Contains("version"))
{
    // do something with settings
}

The other advantage is that when you update your application you can upgrade settings easily. 

if (IsolatedStorageSettings.ApplicationSettings.Contains("version"))
{
    switch ((int)IsolatedStorageSettings.ApplicationSettings["version"])
    {
        case 1:
        {
            // upgrade version setting and add missing settings or change existing settings
            break;
        }
        case 2:
        {
            // normal reading of settings
            break;
        }
    }
}
Even if you never use it for upgrades, at least it is there for a simple check and if one day you need it - you are ready to go!