Nick's .NET Travels

Continually looking for the yellow brick road so I can catch me a wizard....

Unable to Connect or Debug to Visual Studio Android Emulator with Visual Studio 2017 RC

Now I do appreciate that running prerelease software comes with some risk and I’m also aware that emulators are hard to get working 100% right on every machine. Ever since I can remember there have been connectivity issues with Windows Mobile, Windows Phone and now Windows 10 Mobile emulators; whether connectivity meaning to the internet, the local machine or being able to debug an application. So, it came as no surprise that after rebuilding my computer and installing Visual Studio 2017 RC that my installation of the Visual Studio Android Emulator was semi-broken. Turns out I had two issues I needed to overcome.

When I attempted to launch the emulator, I got the following notice, saying that the Internet Connection needs to be configured – this is pretty typical for first run as Hyper-V needs to setup the virtual switches that the emulator image will use.

image

After clicking Yes, the emulator is launched and my application is deployed. Unfortunately when Visual Studio attempts to launch the application and attach the debugger, the application closes immediately. This is again an issues I’ve seen before and in fact it appears on the troubleshooting web page for the Android Emulator (https://msdn.microsoft.com/en-us/library/mt228282.aspx):

- After you’ve run the emulator image the first time, close the Android Emulator

- Open Hyper-V Manager

- Select the virtual machine that matches the emulator you were attempting to run (make sure it’s in the Off state), and click Settings

- Under Processor –> Compatibility –> check the “Migrate to a physical computer with a different processor version” checkbox

image

- Click OK

- Important: Make sure you stop and restart the Hyper-V service, otherwise, for some reason the setting is lost the next time you run the emulator.

Having done this I can now deploy and run applications on the emulator. The next issue was that for some reason the emulator couldn’t access the internet. I took a look in the Virtual Switch Manager in Hyper-V Manager (click Virtual Switch Manager from the Actions list on the right side of the Hyper-V Manager management console) and there was only a single “Windows Phone Emulator Internal” switch.

image

I clicked on New virtual network switch, selected External Access and gave the switch a name:

image

Each emulator virtual machine needs to have access to both the internal and external switches, so after clicking OK to exit the Virtual Switch Manager, I clicked on the virtual machine that I want to assign the new virtual switch to. Make sure you’ve stopped the virtual machine (closing the Android emulator will do this). Click Settings, click Add Hardware and select Network Adapter and click Add.image

From the Virtual switch dropdown, select the virtual switch you just created (External Access in my case), and click OK.

image

Now launch the emulator (either via the Visual Studio Android Emulator interface that can be launched from the Start menu independently of Visual Studio, or by attempting to run an application from Visual Studio) and you should now have internet access – check via the web browser in the emulator if you’re in any doubt.

Windows Hello (Beta) on Lumia 950 XL

Yesterday, after my Lumia 950 XL arrived, I noted that one of the two features I was going to try was Windows Hello. I want to start by saying that I now have this on both my Surface Book and the Lumia 950XL, and I’ve been using it on the former for quite some time now. Windows Hello on the Surface Book absolutely rocks – it’s not as instant sign on as say the Touch ID sign in capability on the iphone, which is virtually instantaneous on the latest iphones/ipads, but it is still relatively quick and definitely hands free. The latter is useful if you don’t have the keyboard attached.

Unfortunately my experience on the Lumia 950 XL has been disappointing at best, frustrating in some cases. I’ve gone in and repeatedly try to improve recognition but despite this Windows Hello only recognises me less than 50% of the time. What’s worse is that after not recognising me a couple of times it stops trying and forces me to use PIN to unlock. It would be good if it would prompt and suggest PIN to unlock, followed by perhaps a suggestion to improve recognition (perhaps to allow for different lighting conditions etc) but this should only be a suggestion, the camera should still try to identify me, especially since my head is in front of the camera and it should be able to at least detect the presence of a head, even if it can’t identify that it’s me.

The disappointing thing is that even when it does recognise me, it’s no quicker than me swiping up and entering my 4 digit PIN, and you look much less of an idiot doing it. I feel that the integration of a finger print reader would have been much better – less chance of you putting your finger in the wrong place and less environment factors to account for. Not to mention the technology is probably cheaper than the camera required to do Windows Hello with a camera.

This bring me to the final point of this post which is that I’ve bought a production device which comes with the RTM build of Windows 10 Mobile. Now of course, Windows is now a service, which means that patches and updates should come through progressively but at this point no updates have come out for regular customers. If you go to Settings and look at setting up Windows Hello, it is clearly marked as Beta…. WTF! Why have I got Beta features on a device I’ve paid a lot of money for? I don’t know when it became acceptable to ship Beta features to end customers but I think it traces back to Google (if you recall Google was in Beta for years before this tag was removed from their service). Beta testing is there for a purpose, to iron out bugs before you ship to end customers. Now that’s not to say that you can’t have some end customers as beta testers, but they should be invited/request to take part, rather than assume that every customer will tolerate unpolished, incomplete or broken features. Microsoft shipping Beta features to end customers just points to why Apple dominates the mobile market and why iOS customers rarely switch to other platforms.

Microsoft Lumia 950, Windows Hello and Continuum

Due to an issue with the USB dock on my Lumia 640XL preventing me deploying apps for debugging, I went ahead and ordered a Lumia 950 XL which arrived today. The unboxing experience went well and as per most new phones there’s the normal down time whilst you transfer and reinstall apps on the new device. There were two features that I really wanted to try out:

Windows Hello

I’ve been using my Surface Book for a while now, so I’m used to the speed and convenience of the Windows Hello sign in experience which means I can just look at my monitor and it signs in. On the phone the experience is basically the same – it looks for you and signs you in. However, I do feel that it’s actually slower than simply tapping the pin code. At this stage I’ll leave Windows Hello enabled but I suspect that it may annoy me, more than it is a convenience.

Continuum

I don’t have one of the continuum docks yet, and since I purchased a grey-imported phone I wasn’t eligible for http://microsoftdisplaydock.com.au/, the Microsoft Australia offer for getting a free dock (personally I think this should be open to anyone willing to sync $700+ dollars into a Windows Phone at this point given the dire lack of feature complete apps). However, I do have a TV that has a Miracast dongle (https://www.microsoft.com/en-ie/mobile/accessory/hd-10/) attached to it, so I went ahead and tapped the NFC pad, and 10 seconds later the device was connected, displaying out my TV. The phone turns into a track pad and the whole TV is used for whichever app is being displayed.

I went and downloaded an app we’ve just helped deliver - https://www.microsoft.com/en-au/store/apps/hungry-jacks-shake-win-app/9nblggh648x0. Looks brilliant running at full desktop size on a TV screen.

Microsoft and The Smith Family via the #WeSpeakCode Program Delivers Coding to Students at Mitchell High School on Windows 10 as part of #UpgradeYourWold Campaign

Yesterday I had the privilege of being involved in the delivery of introductory computer science and programming material to year 10 and 11 students out at Mitchell High School in Blacktown. The material was from http://studio.code.org which has a fantastic repository of material for high school students (specifically https://studio.code.org/s/20-hour which is the course we were delivering).

This program was a combined initiative from The Smith Family and Microsoft and the first day (yesterday) aligned with the release of Windows 10. It was fantastic to see the energy in the room and the excitement from the students as they played and explored all the new features of Windows 10.

It was also great to see the media pick up what a great experience this was:

http://www.smh.com.au/national/education/sydney-school-students-get-a-taste-of-careers-in-computing-and-agriculture-20150729-gimzax.html

http://www.theaustralian.com.au/business/technology/windows-10-australian-students-pass-their-verdict/story-e6frgakx-1227461837728


Microsoft Partner, Office 365 and Visual Studio Online

This is a somewhat off-topic post which only applies to Microsoft Partners who happen to use Office 365 and Visual Studio Online. As a Microsoft Silver Partner we have a number of licenses which we’re able to use internally. This includes a number of MSDN subscriptions which can be assigned to staff and Office 365 seats.

Over the last couple of weeks we have migrated across to Office 365 (this was actually done over a 24 hour period as it was relatively simple to move from one hosted exchange account to Office 365). One of the awesome things about Office 365 is that users belong to the Azure AD tenant (ie we have builttoroam.com set up as a tenant and all Office 365 users with an email address of ***@builttoroam.com belong to that tenant).

We’ve been using Azure for development for a long time but as Azure AD is still in its infancy we were originally just adding staff in based on their Microsoft Account. We also did the same for Visual Studio Online. All in all this was quite messy and felt very disconnected. Well today we took the plunge and connected Visual Studio Online to our Azure AD account. To make sure the transition went smoothly we have temporarily added the Microsoft Account for each staff member to our Azure AD tenant – this will mean that in the short term they can continue to access VSO using their Microsoft Account. Going forward we would expect that everyone will start to use their workplace account (ie their ***@builttoroam.com Azure AD account) to sign into both the Azure portal and Visual Studio Online.

Here’s where the issue is. Currently in Visual Studio 2013 you can online sign in using a Microsoft Account (this is fixed in Visual Studio 2015 where you can both sign in with a workplace account, and you can have multiple accounts signed in). The upshot is that the staff will have to sign into VS2013 with their Microsoft Account, and then connect to VSO using their workplace account – this seems simple enough, right! wrong! well partially right. Firstly, we still need to assign the MSDN subscriptions to the staff. After being assigned a license, the staff simply go to MSDN and activate the subscription. This gives them a license to use Visual Studio 2013 which is automatically picked up when they sign in using their Microsoft Account.

The issue is that if they then go to Visual Studio 2015 and sign in with their workplace account, they won’t have access to the MSDN subscription (since it’s associated with their workplace account). The solution is to go to their MSDN subscription details (signing into msdn.microsoft.com with their Microsoft Account) and under the Visual Studio Online section, click the Link workplace account option and enter their workplace email address. After doing this, Visual Studio 2015 will pick up the linked MSDN subscription and license, as well as picking up the Visual Studio Online projects in the Team Explorer window.

The upshot is that after doing all this, staff should be able to sign into Visual Studio Online, Office 365, Azure Portal and Visual Studio 2015 using their workplace account. It’s only Visual Studio 2013 where they will have to sign in with their Microsoft Account, and then connect to VSO using their workplace account.

“Ello” who built this rubbish

So after requesting an invite so long ago that I’d forgotten I had a passing interest in the site, I final received in invite via an email from someone called Todd, who I can only assume is related to the site somehow. Anyhow, after signing up on my mobile I wasted a couple of minutes attempting to browse the site and work out how to do simple things like post. In the end I figured I must be missing something, or that perhaps the site wasn’t rendering properly on my Windows Phone. That was a day or so ago; today I remembered that I was supposed to go back and take a look on my laptop. In doing this, again I was woefully disappointed. So much so that I went out looking to see what others had said about the site. The good news is that I’m not alone – for example a post by the Lion of the Blogosphere (http://lionoftheblogosphere.wordpress.com/2014/10/02/review-of-ello/comment-page-1/) sums it up nicely:

But now let’s get to the part about Ello that sucks. The website is a confusing buggy piece of crap. It took me an hour to figure out how to post a photo and two paragraphs of text under it.

I couldn’t have said it better myself. What a complete waste of my time. The site might look ok but the UX is dreadful – there’s no clear call to action; nowhere to start on the page; no obvious way for someone new to get started.

Anyhow, I think I’ve hated enough on this site – needless to say I won’t be going back in a hurry.

Demo rule #1 practice again and again and again, particularly the night before….

Tomorrow is round 2 of TechEd Australia and after my demos all seemed to go well in Melbourne I figured I was all set. However as I usually do I wanted to double check that everything was going to work (particularly since I’m running the Windows 10 preview build). Anyhow, it’s a good thing I did because the wonderful Azure team have changed the syntax of one of the manifest files I have to manually edit mid-way through my first session. The step I walk through is actually taken from a post over on Azure Mobile Services site (http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-dotnet-adal-sso-authentication/) and includes this change:

image

Well, no more – if you try to do this you’ll find that the appPermissions node doesn’t exist in the manifest file. Luckily I have a working mobile service with this change already applied, so I figured if I download the manifest file I should be able to see what’s changed. It turns out that the syntax has changed and that instead of replacing the appPermissions node, you now have to replace the oauth2Permissions node ie change:

"oauth2Permissions": [],

to

"oauth2Permissions": [
    {
      "adminConsentDescription": "Allow the application access to the mobile service",
      "adminConsentDisplayName": "Have full access to the mobile service",
      "id": "b69ee3c9-c40d-4f2a-ac80-961cd1534e40",
      "isEnabled": true,
      "origin": "Application",
      "type": "User",
      "userConsentDescription": "Allow the application full access to the mobile service on your behalf",
      "userConsentDisplayName": "Have full access to the mobile service",
      "value": "user_impersonation"
    }
  ],

The upshot of this is that had I just assumed that my demos would all just work tomorrow I would have been fighting this fire on stage (argh). Moral of the story is practice, practice and practice some more – you never know when the demo gods will strike, and it’s best to be prepared when they do.

Bridging the Gap – One of the perils of Software Development

This morning one of my “connections” over on LinkedIn posted this image illustrating the difference between what a client wants and what they have budget to pay for:

1782026_10152653144134896_1988580111_n.jpg

This made me think of all the parts of any software development project where there is a potential “gap” that we as software developers spend our time trying to plug. Here are just a couple of the typical gaps we try to mitigate:

Requirements – We try to minimise the gap between the documented requirements for a project and what the actual requirements of the end users are. There are several approaches to solving this but in my experience having a close working relationship with the end users is definitely a step in the right direction. Get early version to them for their comment as soon and as frequently as possible.

Development – Here we’re trying to minimise the gap introduced by developers when actually implementing the requirements. Gaps introduced here can be due to lack of understanding of the requirements, issues raised that prevent the requirements being delivered as specified or just development errors.

There are a ton of other places during the software development process where gaps are introduced. In fact if you think about every conversation you have regarding a feature, there is always a risk that you’re introducing a gap as a result of miscommunication or a lack of understanding on what needs to be delivered.

Sochi Apps for Windows Phone but not Windows

The Unwired has a good summary of the two Windows Phone applications covering the Sochi winter Olympics. I had already downloaded them yesterday and must admit I was quite impressed with the attention to details. The apps are clean and responsive – of course, I reserve the right to change this opinion when the event actually starts and I want to see actual results and to be notified when events are on.

I just took a quick look on the Windows Store but alas there are no official applications there. There are a couple of third party applications but no official ones.

Top Social Apps for Windows Phone from fellow MVP

image

Having recently published his Windows Phone client for Tinder, I figured it’d be worth calling out some of the awesome apps Rudy Huyn has produced. I already knew most of the popular apps but what surprised me was that none of the app he’s got listed have a rating of under 3 stars. Great work Rudy – here’s a couple of the more recognisable apps for you to download and try.

6snap6tag6sec6tindrWikipedia

Framework Exceptions in Windows Phone

One of the switches that I often enable in Visual Studio is for it to notify my whenever an exception is thrown. This includes exceptions that are thrown internally by the .NET Framework. To enable this option, launch the Exceptions window from the Debug menu.

image

Select the Common Language Runtime Exceptions and check the Thrown checkbox. Click OK to apply this change

image

Now when you run your application you will see any exceptions that are raised, even if they are handles by you or the .NET Framework. Unfortunately sometimes this can be a bit of a drag because the .NET Framework does quite often throw exceptions, sometimes for legitimate reasons, sometimes not so. One such case is for both the CheckBox and RadioButton (actually the ToggleButton which is the base control is the source of this issue). After enabling Exceptions, add the following xaml to a new project.

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <CheckBox Content="Checkbox 1" />
</Grid>

Run your application and you will see the following, completely meaningless, exception being raised.

image

If you look at the call stack, apparently something is calling ToString on the ToggleButton control (ie the base control for the CheckBox you just added).

image

If you examine the ToString code, you’ll see something similar to the following, and you can see the reference to Resx.GetString. From the callstack this seems to be the issue.

public override string ToString()
{
    string text = base.ToString();
    string text2 = (base.Content ?? "").ToString();
    bool? isChecked = this.IsChecked;
    return string.Format(CultureInfo.InvariantCulture, Resx.GetString("ToggleButton_ToString_FormatString"), new object[]
    {
        text,
        text2,
        isChecked.HasValue ? isChecked.Value.ToString() : "null"
    });
}

Following this even further you eventually get to the internal Resx constructor where you can see that it attempts to load an assembly (see second line of the above callstack). This is the line that is failing, because the System.Windows.debug.resources assembly doesn’t exist for us developers Sad smile

internal Resx()
{
    Assembly assembly = base.GetType().Assembly;
    this.resources = new ResourceManager("System.Windows", assembly);
    string assemblyString = "System.Windows.debug.resources, Version=2.0.5.0, Culture=en-US, PublicKeyToken=7cec85d7bea7798e";
    try
    {
       Assembly assembly2 = Assembly.Load(assemblyString);
        this.debugResources = new ResourceManager("System.Windows.debug", assembly2);
    }
    catch (FileNotFoundException)
    {
    }
    this.fallbackResources = new ResourceManager("mscorlib", typeof(object).Assembly);
}

 

The work around for this is relatively simple. Create your own Checkbox class that inherits from CheckBox and override the ToString method.

public class MyCheckBox:CheckBox
{
    public override string ToString()
    {
        return string.Empty;
    }
}

Add this to your layout in place of the CheckBox

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <PhoneApp23:MyCheckBox Content="Checkbox 1" />
</Grid>

Run: Look, no Exceptions!

NOTE: Whilst the fact that the exception is thrown in the first place probably isn’t great coding, it has little, if any, effect on your app running in production. I’ve described this work around purely to get around the annoyance of the FileNotFoundException being picked up (the other way would be to specifically exclude this type of exception in the Exceptions dialog). Some ad-hoc testing indicates that this exception has an insignificant effect on performance or rendering times.

Sydney Hobart Yacht Race and the Lack of Sailing Apps

Recently I enjoyed watching the highlight from the Perth 2011 ISAF Sailing World Championships but was disappointed in the lack of mobile accessibility for results and information about the event. Whilst the website was functional, and actually looked quite good if you were viewing it on a desktop/laptop computer, it left a lot to be desired when accessing it via a mobile device. It seems surprising that given the push by the sailing fraternity to raise the profile of the sport that there was no consideration given to building an application for any of the mobile platforms.

The second failure of the sailing community is this year's Rolex Sydney Hobart Yacht Race. Personally I’m not a big fan of the design of the website but I do like the Yacht Tracker system they’re using. Unfortunately again there are no apps available for any of the mobile platforms as far as I’m aware.

Yesterday after watching the start to the Sydney Hobart on TV (yes, even though I live in Sydney I actually think you get a better view of the start via TV that fighting the crowds at either of the heads) I decided that I would put together a quick Windows Phone application using the data exposed by Twitter, the RSS feed and the data feeds that Yacht Tracker uses. I haven’t bothered to submit the app to Marketplace as the race would be over before it gets approved. Unfortunately this means that only users with an unlocked/developer Windows Phone can use the app.

My apologies if you can’t run the app, send me an email via the website and I’ll see what I can do to get you a trial version. I’ve also included the following screenshots so you can see what you’re missing (remember, this is less than 8 hours of work!)

sh1 s2 s3 s4

 

Updated 28/12/2011 00:20: Now supports background agent support for updating primary live tile with race leaders.

Updated 28/12/2011 11:13: Added multi-tile support, boat details, full page map support and about page.

Android Frustrations

This evening I spent a number of hours chasing my tail.  All I wanted to do was to debug the very simple Android application. I figured all I would have to do is go ahead and purchase MonoDroid (you can only debug using the emulator with the evaluation license, which is painfully slow and periodically breaks). Unfortunately this was not the case.

It turns out that my Samsung Galaxy S which is less than a year old is running Android v2.1 which is too old for the MonoDroid toolkit. I then spent the next hour fighting Samsungs poor excuse for a desktop application, Kies. It doesn’t help that the new version (v2) isn’t compatible with their less than a year old devices. I then managed to locate an older version (v1.5) which was compatible but for the life of me I couldn’t get my device to connect to the software. Finally after tweaking all sorts of things I got it to connect only to discover that the software didn’t have an update for my Galaxy S. ARGH.

Ok, back to basics – lets just get a cooked ROM and apply that. Sure enough I found instructions on how to a) root my Galaxy S and then to b) install Android 2.3.3:

How to Root Samsung Galaxy S

http://www.pathikshah.com/blog/root-samsung-galaxy-s/

Install Android 2.3.3 Gingerbread on Samsung Galaxy S

http://www.pathikshah.com/blog/install-android-2-3-3-gingerbread-on-samsung-galaxy-s/

After doing all that I now have a device I can debug to from Visual Studio 2010 using MonoDroid. This is way way way too painful, but to be expected from Google and Android.