Posts

An unexpected exception which resulted in a gentle reminder of how Linq works...

Image
Tonight I spent some time continuing my port of a Mobile Application I developed a few years ago over to UWP. As it was built in Xamarin.Forms , which also supports UWP, so far its been a fairly straight forward process. During testing tonight however I kept getting an uncaught exception every time I tapped a list item.
Specified argument was out of the range of valid values - Source Xamarin.Forms.Core
Now first I double checked the code and found UWP, iOS and Android all run the same code and nothing had changed, so I hadn't accidentally broken anything. What I did note was the pages that didn't have grouped list items worked fine, where as grouped lists always crashed. This lead me to take a look at my ItemSource code for the listview.

Now those observant might notice in the pic I'm inspecting the listingNavigationItems, and like I might have realised the potential issue. Dependent on whether grouping is enabled I either return the first of my grouped sections OR I retu…

WebUSB - An unexpected update...

Image
In January at my new(ish) user group Momentum Meetups, I presented on "Reaching out beyond the Chrome" (although suffering from food poisoning so I was definitely going green at points!). It included WebUSB and WebBluetooth. I was excited by how powerful it was and even had a colleague present something we had been prototyping in out work place.

During the talk I mentioned security and how it had been designed so it only works on https and there's a permission model where you have to approve the device before it can be used.

Unfortunately this week it came to light that Authentication devices could be bypassed via USB. These devices are a great way of proving you are who you say you are on the web beyond basic 2FA text's or applications. So being able to be able to bypass them via WebUSB is a big deal :(

A few days later Google then disabled WebUSB by default effectively killing it off until such a time where its made secure.

I'm now worried about the future of W…

a different day a different msbuild issue...

Image
Recently I started working on a small tweak to an existing web project, its a small internal dashboard sort of thing nothing complicated about it.

However after I started working on it I found I could no longer build the project it came up with:
): error CS1525: Invalid expression term 'throw' ): error CS1002: ; expected  error CS1043: { or ; expected  error CS1513: } expected : error CS1014: A get or set accessor expected : error CS1513: } expected  When I looked at the location of the build errors I could see some perfectly valid code, all be it C#7:

 public IEnumerable<AttemptResult> Attempts
{
get => _attempts;
set => _attempts = (value ?? Enumerable.Empty<AttemptResult>());
}

Why would it not like the C#7 code, i'm in VS2017 it should all be correct, when I double checked the language setting under Advanced Build Settings it correctly had C# latest major version, so it wasn't a case the project had got pinned to a language version.

I next turned to…

project.json doesn't have a runtimes section, add '“runtimes”: { “win”: { } }' to project.json within a .Net Class Library

Recently I've started experiencing weird build errors when switch branches on a product.
Error : Your project.json doesn't have a runtimes section. You should add '"runtimes": { "win": { } }' to your project.json and then re-run NuGet restore. It's a weird sounding error and the fact it mentions project.json makes it sound like a hangup from when .Net Core and Standard were using project.json files before they became .csproj files again.

My first thought to resolve this is always try a clean and build, particularity when swapping branches things could get left hanging around but this doesn't work.

I took a closer look at the projects affected and the cause is to do with one of the branches of our product. It's an early development branch of a new feature where the project has become .Net Standard 2.0 but also targets .Net 4.5, where as the support and main dev branch are still the full framework class libraries.  The cause is most certai…

The curious case of hidden form fields changing their value....

So today I was looking into an odd issue our CEO experienced using a website. He would get a password reset email and upon following the link and entering a new password it would fail to change with a cryptic message.

I said I'd have a quick look and see what I could see. I signed up and triggered a password reset and found no issue. I was using Chrome and assumed he had but it turns out he was using Safari on his Mac not Chrome. So I loaded up Safari on my Mac and used my link to again find no issue.

To be thorough I asked him to send me his link, in Chrome no issue however this time in Safari I hit the issue. My first thought led me to then check what was posted to the server and sure enough in Chrome I could see an encoded access token sent but in Safari I saw my email address sent. I tried this on my CEO's machine and his machine posted his email address, it looked like Safari was autofilling hidden form fields as well as visible ones!

This is crazy!

So I performed a quick…

GZip Compression of JSON and IIS

Image
Recently in work we've been monitoring the data usage of one of our main products. In today's modern age as developers we often think of bandwidth as cheap and usually have nice fast internet connections and don't overly worry about the *bloat* of our pages and applications.

Our application is often used on 4G connections and whilst they are fast and performance of the application is overall acceptable we found that its data usage was higher than expected and caused us a few concerns over the amount of GB consumed per month.

We've benefited from GZip compression for many years now and most people don't even think about whether its enabled or running as well as it should be. Turning it on and off is usually as simple as turning on the feature in Server Manager and then enabling Static Compression (for your static files, CSS, Javascript etc) and then enabling Dynamic Compression for the generated HTML etc. So it was assumed all was well.

As I'm paranoid about thi…

ADO.Net Async with Transactions... A Lesson Learned

Image
Last night I was testing out a new WebApi Filter I've added to a project, its fairly simple, log some data that comes from a HTTP header to the DB.

This particular project has no Entity Framework or anything, just simple ADO.Net, in fact I think the project has 3 stored proc's in total.

I tend to Async all the things by default so when I originally wrote my DB code I had:

using (var conn = new SqlConnection(_connectionString))
{
     await conn.OpenAsync();
     using (var transaction = conn.BeginTransaction())
     {
          var command = conn.CreateCommand();
          command.CommandText = "[Api].[LogDeviceRequest]";
          command.CommandType = System.Data.CommandType.StoredProcedure;
          command.Transaction = transaction;

          command.Parameters.AddWithValue(//etc          try
          {
             await command.ExecuteNonQueryAsync();
          }
          catch
          {
             transaction.Rollback();
             throw;
          }
          transacti…