Posts

x86 .Net Core application fails to launch and debug via Visual Studio 2017

Today I had a random issue following changing one of my .Net Core projects. Usually I run these AnyCPU but this one needed to be X86 due to a third party library. I've done this before and had no issues but today VS seemed to launch the app and then immediately quit with an error exit code but no useful information!

So far whenever I hit something like this I always try and run it via the console using dotnet run in the project directory. Fortunately this showed the issue straight away:
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.5' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files (x86)\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
 …

The mysterious case of being unable to debug a .Net Core Console application using Visual Studio 2017

Image
This morning I had a very frustrating time. It started off well and I was continuing my drive to convert alot of our hardware services from .Net Framework over to .Net Core. Phase 1 is simply .Net Core running on Windows but then Phase 2 is true cross platform. To date its gone very well and I'll probably write about it further another time.

This morning I was continuing to port code across, mainly making our libraries .Net Standard 2 or .Net Standard 2.0 with .Net 4.5 multi targeting. All worked fine until I converted my final library. The app built, it ran and seemed to be working fine however all of a sudden none of my breakpoints in Visual Studio worked.

During this entire process I have found I've hit many build / compile issues when switching between branches and have often had to nuke my obj folders or do a git clean -xdf but this was not the case. Everything worked bar the breakpoints. The usual tricks didn't work, I even reboot my machine and then checked out the …

UWP WebView Intermittently Fails to Load in a Xamarin.Forms App - Resolved!

As I've previously mentioned I've been porting an existing Xamarin.Forms app over to UWP and tonight I've had to tackle an annoying bug which was quite difficult to overcome and I thought worthwhile sharing.

The bug occurs when loading WebViews with HTML directly rather than a URL. I found that roughly 1 in 5 page loads ended up a blank page being rendered. As this is now the third platform for the App I was fairly confident the html and everything was correct.

First of all I suspected a layout issue and maybe the width/height was being messed up so I added a background colour to the control but this always rendered. So not a layout issue.

A quick Google led me to Johan Karlsson's post on events needing to be added on the main UI Thread this seemed better at first but i ended up still hitting the issue 1 in 10 page loads.  More googling led me to a Xamarin bug with the issue but no resolution :(

Taylor Buchanan comments on the bug with a work around however I found thi…

Auto Collapsing Master Panel inside Xamarin.Forms UWP app.

Recently I've been migrating a Xamarin.Forms application which works on phones and tablets over to UWP so that its compatible with Windows 10 and available on the desktop.

Most things have ported well and after a few tweaks most things are running. However during testing I noticed something odd. I use a master detail page to provide a navigation pane and then a details pane. On phones the navigation page is shown and hidden as expected. On tablets if landscape the menu is always open and if portrait it pops up over the details. Now on UWP it behaves as the tablet however I also expected if the window became small or docked to the side of the screen the menu would again turn into a pop over, but Xamarin.Forms doesn't support this by default.

It is however quite easy to support this via a custom renderer. We can override the elements size changed and determine the size of the element. If the size is less than the minimum we want the menu to be automatically opened for we can hid…

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…