Can’t open an attachment in Windows 10 Mobile–try forwarding your e-mail

Every now and then I get an e-mail in Outlook with an attachment that requires me to click to download the full message, after which the attachment doesn’t seem to be properly aware of it’s file type.  Sometimes the attachment even says something like Invoice.pdf, but when you tap on it to open it you get a dialog asking you to CHOOSE AN APP.

          Original Email         Tap To Open Attachment

Saving the file and trying to open via the File Explorer app doesn’t work either.

I discovered the solution by accident, as I tried to forward the e-mail to another e-mail address (GMail) with the hope that it could parse the attachment MIME type correctly.

Here’s the wierd bit, the draft created after you click on Forward shows the attachment with the correct file type.  Tap on that attachment and it now opens in the default application (in this case the PDF opens in Edge which now previes PDF files).

         After Clicking Forward, Draft Email         Tap To Open Attachment In Forwarded Draft

All seems a bit crazy but it’s a very quick work around for a stupid bug.

Be careful how you filter .NET Exceptions

Here’s a very silly issue I hit the other day.  It involves the classic use (or abuse?) of the LINQ operator SingleOrDefault but unexpectedly getting more than one result returned.  In this case an upgrade to a component had changed how data was stored in a SqlLite database; we hadn’t changed the schema, just the number of versions of data we stored per item.

It was quickly found and we placed an exception around our call to SingleOrDefault and filtered the exception to clean up the database, as shown in this simplified code.

try

{  

  getDocument = DocStore.SingleOrDefault(d => d.SelfLink = doc.SelfLink); 

}

catch (System.InvalidOperationException ex)

{    

  if (ex.Message == “Sequence contains more than one matching element”)  

  {     

    CleanUpDuplicates(doc.SelfLink);  

  }  

 else  

 {    

    throw;  

  }

}

This was all caught in regression testing, had more testing to verify the fix and so we were safe to release for upgrades.

Then we get a support call from a test user who says the very situation that we believed we had fixed had just occurred with their system.  A quick check in the logs and it is indeed the same issue.  Only, they are running the system on a Norwegian language version of Windows.  Who knew that the .NET framework very kindly provides localization for exception messages?  This makes sense, it’s the kind of thing a user might see in a dialog box.  Here is what “Sequence contains more than one matching element” becomes in Norwegian,

        Sekvensen inneholder mer enn ett samsvarende element

Oh dear.  So our filtered exception handling has failed when used on a non-English system.  Instead we are now catching that InvalidOperationException, then performing a proper check for multiple rows before dealing with them, rather than relying on the text of the exception message.

Lesson learned.

AWS Lambda support in .NET – NDC Oslo

One of the interesting talks on my first day at NDC Oslo this year was from Norm Johanson who works for Amazon within AWS cloud services.  He ran through the tooling for AWS Serverless applications within Visual Studio 2017 (also available for Visual Studio 2015). 

While the Visual Studio integration was slick, more interesting for me was the command line integration with the .NET CLI, which allows you to create new .Net core applications from AWS project templates.  Even better you can deploy the service and invoke a Lambda function from the CLI too. 

There was also a good example of using AWS API gateway to source the static elements of a web site (CSS and HTML) from S3 storage, while the main ASP.NET Core runs within Lambda.

Norm’s slide deck and sample code for NDC Oslo is available on github; https://github.com/awslabs/aws-sdk-net-samples/tree/master/Talks/ndcoslo-2017.

Windows 10 Mobile Creators Update – a personal view

* UPDATE  20 June 2016 *

In the normal patch Tuesday updates my phone received Windows 10 Mobile update 15063.414, and I after deleting my Garmin devices from my bluetooth settings, Garmin Connect was able to pair with a new device successfully.  The Garmin Connect app itself received an update to version 3.19.0.0 a few days later, and it now appears to be syncing activities successfully once more, and most of the time supports notifications again.  The issues with continuum remain though.


I own a Lumia 950 XL (actually I own two, one needed a screen repair and is my backup).  Neither are currently on an Insider Build so I was excited when Windows 10 Mobile Creators Update came out on production devices in early May, and I quickly updated both devices.  I thought I’d leave it a bit of time to bed in before I gave my view on this update.

The Good

It does appear to be a bit faster, and the Edge has new features which I’m enjoying.  There’s still a flurry of updates to all the core apps, some less welcome than others – Groove has taken a step back with some of the layouts, but mainly it’s positive.  The voice recognition seems to definitely be improved – coping much better with wind noise while cycling when replying to a text message through my Bluetooth headset (quite a challenge to voice recognition).

Subjectively there appear to be a few more occasions where the phone hangs at random – although that may be before I tracked some down to continuum.  Windows 10 has always been a bit temperamental about using the camera from the lock screen, often not responding after taking the photo and viewing it, and I don’t think that has changed.

The Bad – Continuum

I connect my phone to a continuum dock at work, with a standard mouse and displaying on a 24” monitor.  It’s a great way of using Groove to play music, and muck about with playlists of radio 4 podcasts.

As I mentioned above, one of the those more frequent crashes I can now definitely repeat.  It occurs when you phone is connected to the continuum dock, but has locked it’s screen and switched off the screen.  If you disconnect at this point, it is highly likely that the phone will no longer switch on.  If you get it connected back to the dock quickly you can recover, turning on the phone, waiting for the lock screen and then removing from the dock.  If you don’t re-connect to the dock the phone remains blank, and it requires a long power button press reset to get it back.

There is also a further Windows 10 continuum bug.  I suspect that to ‘speed’ up the launching of an app which was running on the phone previously, they are no longer ‘killing’ the original app and restarting but activating straight onto the continuum display.  The issue here, is that the app has no idea that it now has a 24” monitor to play with.  This is especially true with Groove which appears without any sensible master/view layout.  It acts as if it only has a single, albeit, very, very wide display.  To solve this you have to kill the app in the app switcher, and relaunch.  Effectively doing what the phone used to do prior to Creators update.

The (downright) Ugly – Garmin Connect

The other heavy use I make of my phone is to use it to transfer data from a Garmin Vivoactive activity tracker that records my cycle ride to work (250km a week) as well as swims and runs.  Last year Windows 10 received a full UWP app Garmin Connect so I can use the very same app on my Asus T100, Linx 7 tablet or 950 XL to sync the data via Bluetooth.  When connected to the phone it also updates the watch with notifications, calendar entries and weather information.  It’s miles better than the USB cradle sync, as that only synchronises activities, not notifications, and requires you to have a USB cradle with you at work as well as home.  It’s also way better than the iOS version of Garmin Connect which looks old and dowdy in comparison with much harder navigation of the app.

The moment the Creators update was installed I struggled with synchronizing data, and a Garmin device I received back from repair refused to pair with Garmin Connect at all.  That left me with one watch that can sync notifications, and another than can’t, and even the one that can still connect can only support very small sets of activity data, such as swimming.  Any activity with any serious amount of GPS data fails.  Reading release notes and browsing some forums, it looks like the Creator update contained improved Bluetooth LE connectivity.  I suspect they subtly changed the Bluetooth software stick and that broke Garmin Connect.  I suspect it may be getting timeouts as Bluetooth LE might not like supporting long lived Bluetooth operations.

It’s been well discussed on the Garmin Forums here, and there is a Garmin FAQ regarding the issue that leads to a Windows Answers forum post which pretty much says the ‘work around’ is to roll back to Anniversary Update.  I’m not sure that this is even possible now that the production devices are being updated to Creators Edition and I don’t really consider regressing to an older operating system is a real ‘work around’.

So I’m back to synching my data via a Linx 7 tablet at work, and not being able to have the smartwatch notifications (not a big deal, to be honest).

What’s amazing is that this was a known issue on insider builds and everyone still ploughed ahead as if there wasn’t a problem to be resolved.  Microsoft should be giving Garmin some serious help with this as they have produced a solid UWP app that’s best of breed at the exact point that companies like Adidas have pulled their own fab tracking app (they are closing down their entire miCoach service).

The future

Recently on All About Windows Phone Steve Lichfield provided his view on Windows 10 Mobile And The Future – I can only hope he is wrong and we do get a decent update to the 950 XL that can fix the issues I’ve found above with Garmin Connect.  Everyone talks about the ‘app gap’ on Windows 10 Mobile but it’s not helped by cock ups like this.

The Future of .NET

tldr;

.NET Core – it’s the democratisation of programming again. It’s open to all, let’s welcome everybody in.


One of my reasons for moving my blog from https://geekswithblogs.net/twickers was due to the discussions with friends about reviving the alt.net scene in the UK as we got excited about the possibilities of .NET core and getting our elbows deep in other platforms than Windows.  So this is a joint post with the alt.net stream over at https://medium.com/altdotnet.

I know, you want to get a scoop on my subjective view of the future of .NET – but as George Santayana allegedly said ‘Those who cannot remember the past are condemned to repeat it ’, so it’s time for a bit of history of how I got to where I am as an Application Architect at Huddle, primarily working in C#.  Hopefully some of which might mirror your own experience.

My favourite languages

6502 Assembly

No joking about, this was the second programming language in which I became proficient.  I’d worked through ZX Basic on a Sinclair ZX81, and graduated to BBC Basic on a BBC Model B – oh the luxury of a proper keyboard, decent screen resolutions, and colour!  Of course, with only 32Kb of memory (not all of which was available for your actual programs) you hit the limits of what you could achieve with BBC Basic, both in terms of memory and speed of operation.

So, it was obvious, you picked up the Advanced User Guide and taught yourself 6502 assembly.  Several months later you had a keyboard driven mouse pointer (mice were new, not everyone had them) which fitted into less than 1K including all the core logic as well as the background, mask and pointer that could be loaded ‘underneath’ the user memory.

It was hard work but good fun.  It could also go wrong in so many ways … think C++ random pointers and allocations on steroids.

(You can download the Advanced User Guide from http://primrosebank.net/computers/bbc/bbcmanuals.htm)

Turbo Pascal

University computer courses taught me Pascal, there was no Java yet (I’m old, otherwise why was I learning 6502?).  This was the teaching language of it’s time, with a goal of instilling good practices with structured programming.  It had a reputation for not being suited to real world use outside of academia.

arabicfontBorland sorted out that bad reputation of it not being a workhorse language when it released Borland Turbo Pascal.  I discovered this on a work placement during my university course, and it’s where I experienced my first ever IDE (Integrated Development Environment).  To me, Turbo Pascal defined what a developer could expect from an IDE – decent help, integrated building and compiling, multiple file editing and a decent debugger.  It meant I never went near a make file.  For this I was glad for many years.

Borland Turbo Pascal was based on a compiler created by Anders Hejlsberg, who was a major force behind C# and the .NET framework, see later on in this story.

(image taken from https://freepascalanswers.wordpress.com/2013/09/13/my-fpc-lazarus-story/)

Visual Basic 1, 2, 3, 4, 5 and 6

The reason I’d written a 6502 assembly mouse pointer was due to my neighbours buying one of the first every Apple Mac units in the UK.  I knew the future was graphical, but even though during work placements I touched upon GEM (a rival to Windows) it wasn’t until my first real jobs after university that I encountered Windows 3.0.  Realistically this was the first ‘usable’ Windows, if only because it included decent sound card support and networking that … mostly worked.  So, although I was still writing some DOS programs in Turbo Pascal it was obvious there needed to be a similar tool for Windows.  C and C++ was just too damn hard for most developers especially with the Windows API.

Visual Basic 1.0 for Windows running under Window 3.11Working for a small company inside of Sky Television, we were asked if we could provide the first in house weather system, and we grabbed this new product from Microsoft called Visual Basic.  It had an IDE, you could create forms and just drag and drop controls onto them.  You just double clicked a button and it opened a code window where you added some logic.  You could easily show dialog boxes.  You could access files. You couldn’t do databases properly (that came with the Jet database engine in Visual Basic 3.0) but suddenly everyone could write applications for Windows.

And I mean EVERYONE.  This was the democratisation of programming.  It was fun, like 6502 assembly, but with none of the pain.  You could play.  You could experiment. You didn’t have to know lots of stuff.  It didn’t come with hundreds of libraries or frameworks – it came on three 720K floppy disks; there was no room for them.

Eventually I ended up working directly for Sky Television (now BSkyB).  Those early VB1 programs became VB3 and VB4 programs, with 16-bit upgraded to 32-bit, and by the time we were programming in VB6 we in a full-on COM based world.  The Visual Studio install required CDs, especially for the MSDN help library which was your local version of stack overflow (as long as you could guess what keywords Microsoft had decided to use).  We had distributed systems handling the general election graphics systems feeding anything from Excel spreadsheets to 3D virtual sets with an Oracle database backend pushing Access out of the picture.

Visual Basic 6 was still an easy entry point to programming Windows, but by this point there were two types of Visual Basic programmers; those who dabbled, and those who really understood COM and could produce seriously robust and scalable systems with multiple tiers, reusable objects and threw XML around with abandon.  It had lost the complete ease of use for which it had become loved, and for those who did push it to the limits, the limits were very apparent, and we occasionally looked over the fence at the C++ devs in envy.  Of course, we didn’t quite understand the ‘fun’ the C++ devs were having with implementing COM …

(image taken from http://bc-programming.com/blogs/2013/05/history-of-development-visual-basic-1-0/)

SQL

I also have an affection for a SHOUTY language that to a structured programmer first appears bonkers.  Gone are those loops and if .. then .. else blocks, and you have to change your mind to think it terms of data and linkages between data sets.  Yes, you can use a CURSOR to do a loop, but you shouldn’t.  Really, you shouldn’t.  The challenges in SQL are quite different and the sense of satisfaction from a high performance query getting data back from 10’s of millions of rows of data in seconds is a real thrill.

It seemed a bit niche, until we got LINQ in the .NET framework, and suddenly I could write expressive data manipulation code in C# as well as SQL.  Fab!

C#

Microsoft_Dot_Net_Old_Logo1.157221844.pngBy the late 90’s the combination of C++, Visual Basic 6.0 and COM looked like it was hitting the limits of its capability and Java was on the ascendance on servers, challenging the sales of Windows Server.  It took quite a few years, and conversion from early projects within Microsoft, but the world received a new framework – the .NET Framework, and a new language, C#, complete with curly braces with very much a passing nod to Java.  The .NET Framework brought standardisation if not open source.  Even the new language C# became a standard as ECMA-334:2003 / ISO/IEC 23270:2003.

I could have moved from Visual Basic 6.0 to Visual Basic .NET but I felt it was genuinely time for a change, and maintaining VB6 code next to VB.NET was just not enough of a context switch to stop you making damn silly mistakes.  The decision was made easier by the lack of VB.NET code samples, and the fact that the simplicity of VB had finally disappeared completely.

In the first version of Visual Studio.NET if you removed the default form from a VB.NET project to replace it with your own, it wouldn’t compile.  There was no helpful VB6 dialog to get you to wire up an entry point to your application.  Suddenly, everyone who used VB was asked to understand the entry point of an application, and how to configure delegates.  It was the end of the democratisation of programming at Microsoft …

… but us old VB devs were having fun with C#, we got proper access to threading, new constructs, and along came all sorts of goodies, like LINQ, generics, Lambda functions and anonymous types and methods.  We could no longer edit and continue, but apart from infamously running a general election system in edit and continue – editing the code live as the results came in, I never considerd it a killer feature.

As I have hinted, all this complexity came at a cost.  Combined with learning proper patterns and practices, getting used to TDD and continuous integration servers, we found ourselves in a place where creating a simple web site would be at least five days – to do it properly.

A contractor, Charles, who I was working with hit this with a web site for a relative.  He

 

was stunned by how something supposedly so simple took so much time and resulted in a web site that required knowledgeable developers to support.  Of course, despite being in a startup, this is the point you had to admit you had finally become enterprise developers.

ASP_Net_Aspx_page_life_cycle

Those enterprise developers who could list all the steps in the ASP.NET page life cycle which became the classic question thrown at Microsoft developer interviews.

It was no surprise that other languages took the place of the missing VB – Ruby (on Rails) and JavaScript allowed much quicker creation of prototypes and small systems.  They might not scale, but neither might the business plan either, so at least you didn’t waste oodles of time creating a gold-plated application that no one used.

(.net logo from http://pcsolutions4all.blogspot.co.uk/2010/08/download-net.html, page lifecycle http://codedisplay.com/asp-net-or-aspx-page-life-cycle-interview-question/)

Summary – other languages

So, my favourite languages are 6502 assembly, Turbo Pascal, Visual Basic 6.0 and C#.  I dabbled in FORTRAN, C, C++ and even Java.

I’ve been digging through JavaScript almost as long as I’ve been programming in C# and while I saw amazing stuff demonstrated by people like Helen Emerson in the early days, it had not become a language I’ve yet come to love.  Neither do I see it as a pariah, it is odd that it gets so much stick from developers who favour compiled languages.  It’s like claiming a screw is a much better version of a nail.  It’s quite a different beast and is more complex both to manufacture and use.

Not just MSDN

I also had the fortune that when I left BSkyB for a short-lived startup I ended up as an owner/contractor working with companies that were not Microsoft only shops.  This meant I was quickly weaned off Visual SourceSafe (which did a great job of getting developers into source code control) and onto Subversion and became pragmatic about tooling and frameworks.

I was hanging round with the guys at London .NET Users, who were remarkably progressive for a user group started at the same time as .NET.  Here was a user group where third party tools such as NUnit, Windsor IoC, and NDoc were considered standard.

There was also an acceptance of more pattern based development, and an eagerness to adopt initiatives such as the ASP.NET MVC framework.  An openness and pragmatism was still combined with a loyalty to the .NET framework and, in general, C# as a top tier language.

In the Java shop I worked, they were amazed when I demonstrated LINQ queries joining database results and in memory arrays together with SQL-like ease.  They quite liked C# generics too.

Why Alt.NET

Part of the atmosphere within that user group was later inspired by the Alt.NET movement originating in Austin in the US.  We were enjoying Alt.NET beers arranged by Sebastian Lambla and weekend un-conference days.

One of those days was where I first learnt how to configure git on Windows (still more of a challenge than it should be).  At an Alt.NET beers I found a job at a digital download startup at Hammersmith where I ended up working with Charles encoding all of the Warner Brothers, EMI and Sony music catalogues to MP3 files and putting all that Alt.NET focus of using the best open source tools combined with .NET to deliver a system for considerably less than our rivals.

For myself, in the UK,

  • Alt.NET was exciting.
  • Alt.NET was open.
  • Alt.NET welcomed everyone.
  • Alt.NET wasn’t elitist.
  • Alt.NET was noisy.

With .NET Core and cloud services, I believe we have the inflexion point in the .NET framework to get people excited again.  We want to throw .NET Core open to everyone, make some noise and make developing fun and exciting.

It’s easier than ever to download a lightweight editor like Visual Studio Code, hack some C# together, compile it and copy it over to a cloud server and have your code running on an AWS Linux box within a few hours.

.NET Core – it’s the democratisation of programming again.

It’s open to all, let’s welcome everybody in.

Get.NET 2017, Łódź–22nd April 2017

GetNetLodz (1)Many thanks to the organisers of Get.NET 2017; Izabela Wawer from Sii Łódź for making sure the speakers and attendees were well looked after and a personal thank you to Michał Śliwoń from the agenda committee for asking me to provide a presentation.  It was a great conference and my first trip to Poland for 20 years, and I had real fun exploring the city, including a 10K run on Sunday morning. You can find some pictures of the city, and the run, on my instagram feed https://www.instagram.com/westleyjam.  I promise, I won’t leave it as long next time.

Presentation now ready for download …

I have uploaded the presentation to github, https://github.com/westleyl/GetNET2017, which includes speaker notes that contain links for the statistics of usage and market value.