Development

JSinSA 2012

Submitted by Robert MacLean on Mon, 05/07/2012 - 13:14

jsinsa

AsHoIrXCEAA2s1YThis past weekend was the ever fantastic JavaScript in South Africa (JSinSA) conference. This year focus was on HTML 5, JavaScript & CSS 3 – easily some of the MOST important topics for developers regardless of platform to know about.

It was it’s second year and while I was very lucky to go to it as an attendee in the first year, this year I was even more lucky to be a presenter at the conference. I was also very lucky to present on a topic I am passionate about: Windows 8.

The talk provided an introduction to Windows 8 & how development works, and in the 45mins I was done, we built an application which could take a photo from a web cam and send it to Twitter (the actual photo is to the right).

You can get the slides and bits from the talk below.

South African Postal Codes for Windows Phone

Submitted by Robert MacLean on Tue, 04/17/2012 - 06:34

1I can NEVER EVER remember the postal code for where I work or where I live – that little four digit number just eludes my brain. So to solve that I thought, why can’t I have EVERY postal code with me always? So that is what I made happen with this simple Windows Phone application: Postal codes!

It is dog simple: one input the name of what you want then hit search and boom results. It includes both street and box codes Smile

For the developers out there, this application source code is available too at: https://bitbucket.org/rmaclean/postal-codes

Windows 8 for the .NET developer

Submitted by Robert MacLean on Wed, 04/11/2012 - 09:55

Last night I presented on Windows 8 for the .NET developer at the fantastic Developer User Group! We had a bumper crowd there which was great and really had some interesting discussions during and after the talk. Thank you to all that attended!

For those looking for the slides, demo script and demo bits they are below!

Why the harder you work to prove to Microsoft you know better, the less chance it will ever happen

Submitted by Robert MacLean on Wed, 04/04/2012 - 16:12

Disclaimer: I do not work for Microsoft and these are my views based on discussions with multiple people at Microsoft which I have stitched together – maybe I misunderstood everyone and this is all wrong too. All examples I use are my own. I am no lawyer – check with a lawyer for legal & license advice.

tl;dr: Microsoft is really worried about being sued and thus is risk adverse to “stuff from the internet”. It is better to tell Microsoft what you dislike, not how to fix it. Learn about licensing content.

Paper Work

A few years ago I went on an amazing trip to work with Microsoft but before I could do that I needed to sign not only a NDA, but also waivers for the work I would do – which makes sense. I did it for free and Microsoft didn’t want me to sue them for money later for my work. Not only that I had to sign them, my employer had to do the exact same thing. Once again because I work for someone else who could claim money from Microsoft and Microsoft lawyers had deemed that a risk and needed to be protected.

This involved a lot of time and money, it is VERY expensive to have lawyers review documents from other lawyers and the DHL the originals half way round the world, but it is far cheaper than being sued.

I know that neither myself of BBD would sue Microsoft for the work I did, but that doesn’t still the hearts of those lawyers who live in a world of ugly mean liars that will cheat the system if it was easy and good. I wish it wasn’t this way but some wishes don’t happen.

The Users Voice

A while back Microsoft started spinning up loads of uservoice.com (UV) sites to collect feedback and I believe they are successful in getting some things changed. There is an odd issue I see on UV especially with how Microsoft deals with it, that being as technology advanced users & developers we are taught to give the most detail as possible – really there is nothing like too much detail… however in UV, it seems that Microsoft ignores them and favours those who do and give very little. A great example of this, is in Visual Studio land where we can compare the current top two ideas: this short idea which is “under review”

image

versus to this guy who has pages of details and even as taking the design and proving a lot of it could work – for all his hard work, nothing.

image

WTF?! Microsoft doesn’t listen to me

If you read both suggestions they seem to say the same thing except the lazy guys one got the reward, right? No – it is more fundamental than that. The first one is really just discussing the what & why the VS colour change that is an issue, the second piece of feedback though is discussing how to fix it. The problem for Microsoft is if they take the second guys stuff, a person who hasn’t signed a waiver, the how guy has a legal ability to sue Microsoft for the money they owe him for work/royalties etc… And Microsoft legal won’t allow that to happen because that is their job, to protect Microsoft legal issues.

This is not a complaint about legal, I am sure they are nice people that are just doing their job and it is annoying their job and my wishes do not align...

The thing about taking the what feedback is Microsoft is pretty safe in taking and improving VS in anyway they see fit and that is why the what & why is under review and not the how.

Licensing & Public Domain

The next that will be brought up is that this is work in the public domain and thus “free”… wrong. Public domain work is more a legal trap than anything, and there is so many steps that you need to jump through to get access to using that “free” work that often it is easier to redo it yourself. This is why ANYTHING you do should have a license, even if you want to just give it away and never see it again or if you want someone like Microsoft to be able to use it.

For software check out a good open source license, such as BSD 3-clause which basically says do what you like with my work and I promise I won't sue you except if you use me as an endorsement for your product which contains my work. For non-code items,  like art, music or blog posts have a look at the creative commons licenses.

Microsoft can fix this too

Microsoft could reach out to people with good ideas and get them to sign waivers (WAY too much work and also maybe risky after the work is provided), but better would be to adopt an approach like StackExchange (SE) does. SE states if you provide feedback on their sites it is creative commons.

Microsoft could do the same and even put in a waiver clause on UV, I don’t know if UV allows for this, but Microsoft is big enough to get it done. It doesn’t solve great ideas that are posted elsewhere, those still required YOU to take the time to learn a little about licensing, public domain and so on and take the right steps so we can ALL benefit… not just the lawyers who get paid to say no.

IntelliTrace vs. PreEmptive Analytics

Submitted by Robert MacLean on Fri, 03/30/2012 - 14:19

IntelliTrace

Visual Studio 2010 introduced an amazing feature: IntelliTrace which allows for deep debugging experiences inside Visual Studio by collecting an AMAZING amount of information (basically a stack trace for every call in your code + meta data) and allowing you to use it later to replay the way the application was used. With this feature you could eliminate those “No Repro” bugs! The catch in 2010 was it was NOT allowed to be used in production. In Visual Studio 11 that has changed and we can use it in production: http://msdn.microsoft.com/en-us/library/hh398365(v=vs.110).aspx & http://msdn.microsoft.com/en-us/hh440472

PreEmptive Analytics

This change in licensing may seem to put IntelliTrace in direct competition with another great tool, PreEmptive Analytics (PA). I have mentioned this amazing tool before and with Visual Studio 11 it is included “in the box” so there seems to be a conflict brewing – but there isn’t.

Two sides of the same coin

These two tools are both part of the collect information so you can react to it later and fix bugs set of tools, but they have very different use cases. IntelliTrace is specific to the scenario of replaying an application for diagnosis and debugging purposes. It is not meant to be an always on tool and it is a tool that writes to a local file that needs to be collected some how.

PA on the other hand is a tool to always have on, it does capture error information but nothing more than the simple Exception + Stack which is not as useful, detailed or integrated into VS when compared to IntelliTrace. In addition PA allows me to do a lot of a lot of analytics on my application that are not possible in IntelliTrace:

  • what features are people using
  • where in the world are they
  • when are they using it
  • what are their machines like

In addition the PA reports get automatically sent to a server (that they run or that you can run if you have privacy/security concerns) so there is not need to waddle around collecting files.

I can also see scenarios that these two work hand in hand – PreEmptive getting higher level info that shows a lot of users having issue X, then the support guys contact some users and do a more detailed capture of the issue with IntelliTrace.

Installing Windows Phone Developer Tools on Windows 8

Submitted by Robert MacLean on Tue, 03/27/2012 - 16:18

The joys of being on the bleeding edge, is we are sometimes bleeding such as the fact the Windows Phone Developer tools have not worked on Windows 8… until now. However the steps to do get this working are not easy and are spread out a bit on the Internet, so this post aims to give you a one stop, quick reference way on how to get it done in five steps.

Step 1 – Get the bits

You will need THREE downloads for this:

  1. The Games for Windows Marketplace Client: http://www.xbox.com/en-US/LIVE/PC/DownloadClient
  2. The Windows Phone SDK 7.1: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27570

    personally I would get the ISO for it from: http://go.microsoft.com/fwlink/?LinkID=226694

  3. The Windows Phone SDK 7.1.1 Update: http://www.microsoft.com/download/en/details.aspx?id=29233

This should set you back 1.1Gb in bandwidth.

Step 2 – Install the Games for Windows Marketplace Client

image

Troubleshooting notes:

Step 3 – Install .NET Framework 3.5

Now pop in your Windows 8 DVD (or mount the ISO), next open a command prompt AS ADMINISTRATOR and navigate to the \sources\sxs folder on the DVD and run the following command. My DVD was mounted on drive F so note you may need to change the underlined part of the command to match your situation: dism.exe /online /enable-feature /featurename:NetFX3 /All /Source:f:\sources\sxs /LimitAccess

image

Step 4 – Install Windows Phone SDK 7.1

Now run the installer for the Windows Phone SDK 7.1 as per normal.

imageimage

Troubleshooting notes:

  • If you get any errors about installing some components, try to copy them from the disk to the desktop – if you get a invalid MS-DOS function error, then you have a corrupt ISO and need to download it all again.

Step 5 – Install Windows Phone SDK update

Almost there, just the Phone SDK update to install!

image

Done!

And there we are, the tiles are on the start screen, Visual Studio 2010 launches (and hurts my eyes with all those colours :P ), the new emulator options are all there in the drop downs and the EMULATOR WORKS!!!!

imageimageimage

Troubleshooting notes:

  • If you have a CPU that supports SLAT (for example a Core i7) you can run Hyper-V on Windows 8, which hurts emulator performance. Turn if off it you can.

Windows 8 Bootcamp

Submitted by Robert MacLean on Tue, 03/20/2012 - 15:54

windows8logo_large_verge_medium_landscapeLast week (14th March 2012, to be exact) I had a great opportunity to travel to Cape Town and present the first ever Windows 8 Bootcamp there! (I missed the first in South Africa by two days, that was presented in Jo’burg by Rudi Grobler).

It was a small event, but it was a great day of learning and sharing and what a lovely place it was to present, as you can see from the photos below!

One of the requests from those who attended the event was the demos & slides – however there is a snag, Microsoft owns the slides and they are not ready for them to be publically shared Sad smile  That said the demo bits are below, so hopefully that will keep you sorted until the slides arrive.

WP_000655WP_000656

Upgrading Visual Studio "11" Developer Preview Metro Projects to Visual Studio "11" Beta Metro Projects

Submitted by Robert MacLean on Thu, 03/01/2012 - 03:14

76451If you created Metro style (WinRT) projects in Visual Studio “11” developer preview (alpha) and you try to open them up in the beta you will have a few load issues. These are ones I have found in my apps so it is not exhaustive, but seems like the most common.

Projects will not load

The projects themselves will not load with the following error: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v1.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. 

The solution to this is to open the project file and navigate to the <Import> node and change the path from v1.0 to v11.0 (see the highlighted extra 1 in the image below that is needed):

image

Compiler Directive

If you used the compiler directive WINRT that has been changed to NETFX_CORE so you will need to update your code.

Package fails to build

The package fails to build/deploy and complains about an InitialRotationPreference attribute. To solve this open the Package.appxmanifest file and find the <VisualElements> node and you should find an line similar to this:

<VisualElements DisplayName="AtomicMVVM Metro Style App Demo" Logo="Images\Logo.png" SmallLogo="Images\SmallLogo.png" Description="AtomicMVVM Metro Style App Demo" ForegroundText="light" BackgroundColor="#000000" InitialRotationPreference="portrait">

What you need to do is remove the InitialRotationPreference attribute from the end, so it ends like this:

<VisualElements DisplayName="AtomicMVVM Metro Style App Demo" Logo="Images\Logo.png" SmallLogo="Images\SmallLogo.png" Description="AtomicMVVM Metro Style App Demo" ForegroundText="light" BackgroundColor="#000000">

Big load failure image from: http://www.hostedfile.com/pictures/76451/big-load-failure.html

How different is Metro Style (WinRT) development really? The beta post

Submitted by Robert MacLean on Thu, 03/01/2012 - 02:56

goodworkNote: Before you read this post, it is using the public consumer preview (beta) of Windows 8, VS 11 & .NET 4.5, so I expect some issues will likely be resolved in later releases. Check the site out for more info!

With the beta of Win8, VS 11 & .NET 4.5 now out I thought I should post again (first post about this can be found here – recommended reading to see how it has improved) how it has improved or changed since the alpha. This is not meant to be an exhaustive list, it is a list of the most common things (where most common is what I use, because I am pretty common Smile with tongue out)

Namespaces

Namespaces have been polished and there is a much better alignment of the new awesomeness to the old so this is getting much better.

#if NETFX_CORE
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml;
    using Windows.UI.Core;
    using Windows.UI.Xaml.Controls.Primitives;
#else
    using System.Windows.Controls;    
    using System.Windows.Controls.Primitives;
#endif

Duplication of INotifyPropertyChanged, ICommand & INotifyCollectionChanged is SOLVED!

I mentioned about the EPIC FAIL of the duplication of core interfaces – that has been solved! SmileSmileSmile

ObservableCollection<T> is broken is SOLVED!

The double facepalm that was breaking ObservableCollection<T> has also been solved – so this means your Metro style apps are more like your WPF & Silverlight apps than ever before.

User Controls must be created on the main thread is SOLVED!

I did not get a stupid behaviour where a user control had to be created on the main thread, and thankfully that has been solved! You can now create user controls on other threads! SmileSmile

IValueConverter has been changed

Previously the Convert & ConvertBack methods second parameter was a string, now it has been changed to a Type. This is a good move as it allows for better compares, but means any IValueConverters from alpha will be broken and it is a simple change:

//Before broken
public object Convert(object value, string typeName, object parameter, string language)

//After changing type of second parameter = working
public object Convert(object value, Type typeName, object parameter, string language)

Good work image from http://bloggers.com/posts/happy-developer-37379

Important changes to Express Editions of Visual Studio "11"

Submitted by Robert MacLean on Wed, 02/29/2012 - 19:34

manualtrafficexchangetipNote: The source of this is the Visual Studio “11” beta Product Guide (http://go.microsoft.com/fwlink/?linkid=243994) so this may change by release.

Today we have five Express products: C++, C#, Visual Basic, Web and Phone however with the launch of Visual Studio “11” we will only have TWO!

These two editions of Express we will have are Web & Windows. I do not believe we will only ever have two editions, as the 2010 Express editions grew during the product so I would expect a few new ones coming along post launch.

So how does the old Express editions map to the new Express editions?

  • C++ maps to NOTHING
  • C# for WinForm/WPF/Silverlight maps to NOTHING
  • VB for WinForm/WPF/Silverlight maps to NOTHING
  • Phone maps to NOTHING
  • Web maps to Web

Let me reiterate this, if you want to build non-Metro applications (unless they are web) there is NO Express edition anymore for this! The Windows Express edition ONLY allows the building of Metro apps (including ARM). Web dev using Express editions still continue to work as before.

Both Express editions have a new enhancements too, which is a fantastic thing: The ability Version Control & Work Item Tracking with TFS is included out of the box.

For the Windows express edition it has even more enhancements

  • A subset of static analysis (fxCop) for helping developers pass Win Store evaluation
  • Performance Profiling has been added: CPU Sampling for C#/VB/C++ Metro apps and Instrumentation for HTML/JS Metro Apps

Stop/Important image from http://sitechoppers.com/why-it-is-important-to-build-your-downline/