Nick's .NET Travels

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

Certifying and Distributing Windows Store Applications to Earlier (ie Non-Supported) Versions of Windows 10 Mobile

In my previous post on Visual Studio 2015 RTM, Universal Windows Platform (UWP) Developer Tools and Debugging on a Windows Phone device I covered modifying the TargetPlatformMinVersion property in the Visual Studio project file in order to deploy your Universal Windows Platform application to a Windows 10 Mobile device. Granted that this post is probably a little too late, since the next build of Windows 10 Mobile is now out (I'm yet to install it), but it is possible to publish your application to the Store so that it can be installed on a non-developer enabled phone.

Now you'd think you'd just be able to create a Store package with the TargetPlatformMinVersion property set to the required value (in this case 10.0.10166.0 to match what I currently have on my device - see the OS Version attribute in the About screenshot below). Unfortunately this is not the case!


If you do attempt to generate a Store package you'll see an error similar to the following image - "10.0.10166.0" is not a supported value for TargetPlatformMinVersion. Please change it on the Project Property page



Ok, so step one is to revert the change to TargetPlatformMinVersion so that you can at least generate a Store package. From the Project menu in Visual Studio, select Store -> Create App Packages (if this option isn't enabled, make sure you have you UWP project selected in Solution Explorer). Follow the prompts to do a Store build - this should generate an .appx file you can work with.

What we're going to do is manually modify the generated package. From the Start menu, select the Developer Command Prompt for VS2015



Change directories to where the .appx file resides. Execute the following command, substituting you .appx filename. This will extract the contents of the .appx file into a sub-folder called "export"
makeappx unpack /nv /p myapplicationpackage.appx /d .\export
Open the AppxManifest.xml file using your text editor of choice. Locate the line that looks similar to the following and replace the MinVersion with the version number you want to target (ie 10.0.10166.0)

<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10240.0" MaxVersionTested="10.0.10240.0" />
Close and save the updated AppxManifest.xml file. And return to the command prompt and execute the following (again feel free to replace the .appx filename)
makeappx pack /nv /d .\export /p myapplicationpackage-updatedversion.appx
And you're done - submit this package to the Store, and a couple of days later (yes, whilst certification only seems to take a couple of hours, the distribution of UWP apps is very slow at the moment, so expect to wait at least 24hours from when certification is completed) you'll be able to install your application...... of course, all of this could have been saved if you'd just updated to the latest Windows 10 Mobile build, which I'm about to do now!

Visual Studio 2015 RTM, Universal Windows Platform (UWP) Developer Tools and Debugging on a Windows Phone device

If you've upgraded to Visual Studio 2015 RTM with the associated Universal Windows Platform tools, you may have realised that you can't deploy apps to a real Windows Phone that's running the current Windows Insider Preview build for Windows Phone. This is because the version of the SDK, which has a version/minversion of 10.0.10240.0, is higher than what's currently available for the phone. For application development and testing this means using the emulators that ship with the SDK.

Of course, this isn't a great story as lots of developers much prefer debugging on a real device. In fact there are scenarios where a real device is the only way to test some scenarios. I came across the following post that provides a temporary, NON-SUPPORTED solution.

https://social.msdn.microsoft.com/Forums/en-US/46889785-07bd-4e10-9134-e8fa429b1486/uwp-is-it-possible-to-deploy-a-uwp-app-build-in-vs2015rtm-to-windows-phone-running-10010166?forum=wpdevelop

The solution rests on manually changing the TargetPlatformMinVersion property in the UWP project file to be the same as what's running on the phone (in my case 10.0.10166.0). Don't change the TargetPlatformVersion property - doing this will mean that you won't be able to open the project in Visual Studio since that version isn't supported with the SDK.

WARNING: Whilst making this change may mean that you can debug your application on a real device, just be aware that it may through weird errors if you happen to try to access an API that has actually changed between 166 and 240 builds. Your code is still going to be built against the 10.0.10240.0 API set, you're just lying in the package manifest, claiming that your app will run on a previous version.

As you can imagine this has been designed with future versions in mind. If you open the project properties dialog for the UWP application you'll see that on the Application tab there is a Targeting section. In the current SDK there is only one option for the target version and min version. Going forward you can imagine that a future SDK will allow for selection of 10.0.10240.0 (the current version) and a future version (where APIs may have evolved).

 

Application Development Using States and Transitions

Having worked with each of the different XAML based technologies Microsoft has released (WPF, SL, WP, Win, UWP...), I've long been a proponent of the use of visual states. Jerry Nixon discusses using visual states to build Windows 8.1 application. I've written articles that talk about using visual states for changing page layout to reflect states within a view model. Let me talk briefly about why I favour visual states and why the visibility property is often misused.... then we'll get onto discussing using states for building applications.

Developers new to working with XAML discover that they can hide/show items on the page by data binding a Boolean property on the view model (this assumes they're using mvvm/data binding) with the visibility property on an element. This of course requires a Boolean to visibility converter. It works nicely and assuming the developer has implemented INotifyPropertyChanged and is raising the PropertyChanged event correctly, the elements on the page will hide/show as required.

Whilst there isn't anything wrong with this approach, it makes it difficult to design the layout in Blend. In order to hide/show elements, you have to modify the design time data (assuming you've bothered to create design time data). The alternative is to use visual states to describe how the page looks for each state. Blend for Visual Studio includes a States window which allows for one or more states to be invoked, making it easy to create, view and edit visual states, at design time!


Ok, time to move on an talk more about using states as a foundation for application development. Unfortunately we can't jump there yet as we need to first look at different levels of how an application hangs together. Rather than get into a discussion on the similarities and differences between application platforms, let's just look at the Windows platform (this should apply to Windows Phone, Windows 8.x and Windows 10):

- An application typically has a frame, within which it navigates between pages

- A page can be made up of any number of visual state groups, and can have a single visual state selected at any time from each visual state group. Animations can be run as part of transitioning between states.

- Controls (including Usercontrols) can contain their own visual states that determine how they look under various conditions (pressed, checked, selected etc).

What's interesting about this is that the navigation between pages is actually the odd one out. Most application developers devote a large portion of the application development process to ensuring the navigation between pages is correct. They spend very little time working through the visual states of pages (often hacking away at hiding/showing elements on the screen). So, what happens if we make the assumption that each one of these scenarios can be expressed as a series of states?

As a starting point, we'd need a definition of a state. In the past, to keep the states of a view model separated from the visual states on a page I typically create an enumeration which has values that have the same names as the visual states. The view model then keeps track of which state is currently selected. Changing the current state raised a StateChanged event, which is handled by the page where it invokes the GoToState method on the VisualStateManager. My basic definition of a state will be an extension of this where the IStateDefinition is based on an enumeration type (well, at least a struct):

public interface IStateDefinition<TState> where TState : struct
{
    TState State { get; }
}

with a simple implementation:

public class BaseStateDefinition<TState> : IStateDefinition<TState>
    where TState : struct
{
    public TState State { get; set; }
}

And we can then define an interface for an entity which maintains current state, allows for a change in state and raise an event when the state changes:

public interface IStateManager<TState> : INotifyPropertyChanged
    where TState : struct
{
    event EventHandler<StateEventArgs<TState>> StateChanged;

    TState CurrentState { get; }

    IDictionary<TState, IStateDefinition<TState>> States { get; }

    Task<bool> ChangeTo(TState newState, bool useTransition = true);
}

The first instinct would be for the view model to implement this interface, but this won't work since the view model would have to implement the interface for each state group that it needs to track. This means we need an implementation of this interface that tracks current state for each state group:

public class BaseStateManager<TState> :
    NotifyBase, IStateManager<TState>
    where TState : struct
{
    public event EventHandler<StateEventArgs<TState>> StateChanged;

    public TState CurrentState { get; private set; }

    public IDictionary<TState, IStateDefinition<TState>> States { get; set; }


    public async Task<bool> ChangeTo(TState newState, bool useTransitions = true)
    {
        var current = CurrentState;
        if (current.Equals(newState)) return true;

        CurrentState = newState;

        try
        {
            StateChanged?.Invoke(this, new StateEventArgs<TState>(newState, useTransitions));
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
            // Ignore any errors caused by the event being raised, as
            // the state change has still occurred
        }
        return true;
    }
}

We'll use this as the basis from which we can track states at an application, page and control level.







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


Launching Windows Store Applications from Code in Windows 10

On Windows 8/8.1 after installing an application from the Windows Store it was possible to interrogate the registry and find the AppUserModelId which could then be used to launch the application. This process is described in more detail here - http://www.codeproject.com/Articles/542316/Run-Windows-Store-Apps-From-Desktop.

There are a couple of ways to launch the application using the AppUserModelId:

- The first (as the link suggests) is to use the launcher utility that comes with the SDK eg:
C:\Program Files (x86)\Windows Kits\8.0\App Certification Kit\Microsoft.Windows.SoftwareLogo.AppxLauncher.exe “AppUserModelId

- The other way is to use the ApplicationActivationManager (https://msdn.microsoft.com/en-us/library/windows/desktop/hh706902(v=vs.85).aspx) which can be used as follows:

uint pid;
var mgr = new ApplicationActivationManager();
mgr.ActivateApplication("[AppUserModelId]", null, ActivateOptions.None, out pid);

This technique relies on getting the AppUserModelId from the following Registry:

HKEY_CURRENT_USER\Software\Classes\ActivatableClasses\Package\**PackageFullName**\Server

The installation process for Store applications on Windows 10 doesn't create this Registry key, which means we need another way to determine the AppUserModelId. I haven't found a definitive way to do this but I did manage to find a way which seems to work. Essentially you need to append "!App" to the package family name of your application (not the package full name).

If you haven't played around with the powershell commands for installing and querying installed packages, it's worth taking a look. For example to get a list of all packages for a particular publisher you can issue the following powershell command:

get-appxpackage -publisher "OID.0.9.2342.19200300.100.1.1=6434210, CN=Built to Roam Pty Ltd, OU=Built to Roam Pty Ltd"

This will return a listing for each application such as the following:

Which, as you can see contains the PackageFamilyName - add "!App" and you have a string that should work as the AppUserModelId, allowing you to launch the application from code.



Visual Studio 2015 RTM and the case of the missing Microsoft Advertising SDK for Windows 8.1

I just got around to upgrading to VS2015 RTM having run the RC since it was available (just as an aside VS2015 has been the only version of Visual Studio that I've been running for quite some time now). And as Murphy's law goes, the first project I open doesn't build and run - OMG what pain do I now need to endure?

It appears that someone has made the decision to remove the Windows 8.1 Advertising SDK (perhaps due to the recent sale of MS advertising assets), which means my Windows 8.1 application is now missing a reference.  According to the Ads in Apps website (http://adsinapps.microsoft.com/en-US/sdk) the SDK is installed in VS2013 update 2 or later (clearly not the case)

Luckily, a bit of searching revealed the SDK available via Visual Studio Gallery at https://visualstudiogallery.msdn.microsoft.com/3d3fa204-0641-4317-ab2c-50092f732edb

Windows Phone 8.1, Microsoft Lumia 640XL and the case of the Virtual Hardware Buttons

The Microsoft Lumia 640 and 640XL were one of the first Windows Phone devices to take advantage of the move to on-screen hardware buttons. Rather than the traditional hardware buttons for Back, Start and Search, these devices have software rendered buttons (note that there were previous devices that had the buttons as part of the same glass as the reset of the screen but this isn't the same as having them rendered in software). There were some that didn't like this move (eg http://www.7tutorials.com/reviewing-microsoft-lumia-640-xl-good-smartphone-business-users) but an nice effect of them being software is that they can be dismissed off the screen. This means that the buttons can be swiped away, leaving more screen available for applications.

The unfortunately thing about this is that because this feature shipped as an update to Windows Phone 8.1 there isn't good support for detecting when the available screen size changes, often leaving applications either with controls rendered under the buttons, or with empty screen space under the content of the application (where the buttons used to reside).

Side note: Rudy Huyn in his post, "How to test my app on phone with navigation bar and why it matters," covers how to use the Windows Phone emulator to test applications for this behaviour.

I spent a bit of time this afternoon trying to work out a workable solution to this. The result was a bit hit and miss but the following seems to work:

In order to take advantage of the full screen I added the following lines to the end of the OnLaunched method in the App.xaml.cs file:

var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
applicationView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);

The UX of the screen is very basic - it has a background color so that you can see where the page is being rendered and a textbox at the bottom of the screen so that you can see whether an element has been hidden. Note also that the VerticalAlignment of the page is set to Top. This might seem weird but if you don't, as you adjust the Height of the page in accordance with the visible bounds, you'll see the page rendered in the middle of the screen, which is not what you want.

<Page x:Class="AppBarTest.MainPage"
      xmlns="
http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="
http://schemas.microsoft.com/winfx/2006/xaml"
      VerticalAlignment="Top">
    <Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Icon="Accept"
                          Label="appbarbutton" />
            <AppBarButton Icon="Cancel"
                          Label="appbarbutton" />
        </CommandBar>
    </Page.BottomAppBar>

    <Grid Background="LightBlue">
        <TextBox Text="Testing"
                 VerticalAlignment="Bottom"
                 Margin="0" />
    </Grid>
</Page>

The code for this page is where all the hacking happens - essentially it looks to determine how tall the page should be based on the space occluded by the status bar and the input pane. The trick is to make sure this is called anytime something adjusts the visible bounds available to the app.

public sealed partial class MainPage
{
    public MainPage()
    {
        InitializeComponent();
           
        var appView = ApplicationView.GetForCurrentView();
        appView.VisibleBoundsChanged += VisibleBoundsChanged;
    }

    private void VisibleBoundsChanged(ApplicationView sender, object args)
    {
        ResizeMe();
    }

    private void ResizeMe()
    {
        var statusBar = StatusBar.GetForCurrentView();

        var appView = ApplicationView.GetForCurrentView();
        var input = InputPane.GetForCurrentView();
        var newHeight = appView.VisibleBounds.Height + (statusBar?.OccludedRect.Height) ??
                                0 + (input?.OccludedRect.Height) ?? 0;
        if ((input?.OccludedRect.Height ?? 0) <= 0 || newHeight <
this.Height)
        {
            this.Height = newHeight;
        }
    }

Update: You should also attach an event handler to the Got and Lost focus on the TextBox and invoke ResizeMe otherwise there are some scenarios where the TextBox ends up under the virtual buttons

Visual Studio 2015 RC Crashing when installing packages with NuGet

Just spent half an hour trying to install a nuget package…. everytime Visual Studio 2015 would crash. I figured I mustn't be alone, so I went hunting. Turns out that whilst I had the most recent extension available on the VS Gallery, it wasn't actually the most recent. Anyhow –  if you go here there is a link to an updated vsix file which fixed all my issues.

Remote Desktop Connection Fail from Windows 10 Using Azure AD Credentials

Just over a week ago I repaved my Surface Pro 3 to a clean install of Windows 10 build 10074 (since then I've upgraded to 10122) and since we don't run our own domain at Built to Roam I figured I would sign into Windows 10 using my Office 365 credentials (ie my Azure Active Directory credentials). For the most part this seems to be relatively stable except for a couple of scenarios:

Firstly, after the upgrade to 10122 it looked like it had completely junked my user profile as I couldn't sign in using either my PIN or Password. The error was actually a little cryptic as it was complaining it couldn't reach a login server. In the end I rebooted and I was able to sign in fine.

The second, and slightly more annoying thing is that the AzureAD credentials seem to be causing some issues with authentication in a couple of places.

–  The first is with Remote Desktop into a cloud service running in Azure. Normally I would only have to specify my username (eg “admin”) and my password and it would authenticate without any issues. However, now I get the following error dialog

Remotefail

Remote Desktop Connection
An authentication error has occurred (Code: 0x80004005).
Remote computer: xxxxxxx.cloudapp.net

 In the end I prefix my username with “local” (eg local\admin) and it worked fine.

–  The second occurence is trying to connect to a network resource. This network resource is actually a NAS but for the life of me I can't work out what domain prefix to give it. It somehow tries to resolve my AzureAD credentials and then is failing. Very frustrating as I now have to retrieve the data off my NAS using a different computer.

Compiled DataBinding in Windows Universal Applications (UAP)

This question on stackoverflow which references the Windows 10 jumpstart videos (http://www.microsoftvirtualacademy.com/training-courses/a-developers-guide-to-windows-10-preview?prid=ch9courselink) raises the topic of compiled data bindings. Currently there is no documentation about this feature and I doubt that we’ll see much out of Microsoft prior to Build. However, the x:Bind syntax is available in the insiders preview of the Windows 10 SDK so I figured I’d explore it a little.

Let’s start with a simple expression:

<TextBlock Text="{x:Bind}" />

When you add this to a page and run it, you’ll see the Type name of the page displayed in the TextBlock (eg CompiledDataBindingSample.MainPage). In order to examine this further let’s create a simple custom control with a dependency property and corresponding change handler:

public class CustomControl : Control
{
    Windows.UI.Xaml.Markup.IComponentConnector x;

    public string Test
    {
        get { return (string)GetValue(TestProperty); }
        set { SetValue(TestProperty, value); }
    }

    // Using a DependencyProperty as the backing store for Test.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty TestProperty =
        DependencyProperty.Register("Test", typeof(string), typeof(CustomControl), new PropertyMetadata(null, TestChanged));

    private static void TestChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var newData = (d as CustomControl).Test;
        Debug.WriteLine(newData.GetType().Name);
    }
}

Now let’s add an instance of this control onto the page and data bind to the Test property:

<local:CustomControl Test="{x:Bind}" />

When this is run we can set a breakpoint on the Debug.WriteLine and we can examine the newData object. What’s interesting is that the newData object is the instance of the page that is hosting the control. In other words, the value being passed into the binding expression is the page itself (in this case an instance of MainPage) – this explains why in the TextBlock showed the type name, as this is the default ToString() value. This is interesting in itself as it means that the context for data binding with x:Bind is the page itself, in contrast to the default DataContext of null when using Binding.

The other thing that’s worth looking at is the Call Stack window. The first two frames make sense, being the set and change handler for the dependency property but then it gets interesting as it references a class called MainPage_obj1_Bindings with methods such as SetValue_obj3_Test, Update_, InitializeCore, Initialize etc.

image

At this point I think it’s time to go take a look at what’s been generated when the application was compiled. In this case we’ll use ILSpy to get a list of the classes that make up the application. As you can see from this screenshot MainPage has a couple of nested types, MainPage.IMainPage_Bindings and MainPAge.MainPage_obj1_Bindings, along with a field/property combination that exposes an instance of MainPage.IMainPage_Bindings. There is also an additional method, Connect, which has been injected into the MainPage during compilation.

image

A further examination of the base types collection shows that in addition to inheriting from Page, MainPage implements Windows.UI.Xaml.Markup.IComponentConnector, which no surprises defines a method, Connect(int, object). So, what does this method do? Using ILSpy to inspect the contents on the Connect method we can see that it generates an instance of the MainPage_obj1_Bindings class and associates it with the elements on the page (in this case the TextBlock and the CustomControl). Clearly this method is going to be invoked during the initialization phase of a page.

Now, let’s turn our attention to the MainPage_obj1_Bindings class. It would appear that this class has instance variables for each of the elements that has an x:Bind expression. In this case it has variables obj2 (TextBlock) and obj3 (CustomControl). It also has some generated methods such as SetValue_obj2_Text which explicitly sets the Text value on the TextBlock. This makes me think back to a time before data binding where properties had to be explicitly set in code. Whilst data binding has been an effective way for developers to declaratively wire up properties to underlying data, it did add a significant overhead and subsequent performance hit – for large data sets this can be quite significant and hard to work around. By the looks of these generated methods, it would appear that by converting the data binding expression into compiled code, some of the performance overhead of data binding can be overcome.

Ok, so now that we’ve taken a bit of a look at some of the aspects of compiled data binding, let’s go back to XAML and take a look at extending the binding expression to include a path. In most cases we’ll want to bind attributes on the visual elements to properties on a view model. The question is how to do this using x:Bind. Let’s see what happens when we add ViewModel to the binding expression:

<TextBlock Text="{x:Bind ViewModel}" />

Normally, if you add a path to a binding expression that isn’t valid it will compile and run without any issues. In this case, there is no ViewModel property on the MainPage, so when the application is compiled the following build error is generated:

Invalid binding expression 'MyProperty' : Unrecognized property 'MyProperty' at offset '0'

Let’s add a ViewModel property to the MainPage:

public MainViewModel ViewModel { get; set; }

public MainPage()
{
    ViewModel = new MainViewModel();
    this.InitializeComponent();

}

The MainViewModel class exposes a property, HelloText, and implements the INotifyPropertyChanged interface. Of course, normally this would be implemented in a base class with an OnPropertyChanged or RaisePropertyChanged helper method.

public class MainViewModel : INotifyPropertyChanged
{
    private string hello = “Hello World”;
    public string HelloText
    {
        get { return hello; }
        set
        {
            hello = value;
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("HelloText"));
            }
        }
    }
    public event PropertyChangedEventHandler PropertyChanged;
}

In order to reference the HelloText property, we’ll extend the binding expression:

<TextBlock Text="{x:Bind ViewModel.HelloText}" />

Running this appears to work with the text “Hello World” appearing in the TextBlock. Let’s try updating the HelloText. A simple Run method will update the HelloText property every second.

public async void Run()
{
    var i = 0;
    while (true)
    {
        await Task.Delay(1000);
        HelloText = "Hello " + i++;
    }
}

Unfortunately this doesn’t seem to do anything, with the TextBlock not updating. This behaviour is consistent of a OneTime data binding. Let’s add Mode=OneWay to the binding expression.

<TextBlock Text="{x:Bind ViewModel.HelloText, Mode=OneWay}" />

Now the TextBlock updates every second as we’d expect. So it appears that unlike a traditional Binding, the x:Bind expression defaults to a OneTime mode, instead of OneWay. ILSpy also indicates that the MainPage_obj_Bindings has a sub-class, MainPage_obj1_Listener, which is designed to hook up to the INotifyPropertyChanged.PropertyChanged event. This again will help ensure updates are passed to the appropriate elements without any need for Reflection based calls.

Build it Beta for Windows and Windows Phone

Over the last couple of weeks we’ve done some major work to Build it Beta which will significantly improve and simplify the process of getting Build it Beta installed and setup across Windows and Windows Phone. If this is the first time you’ve heard of Build it Beta, it is a home-grown solution for the deployment of Windows platform applications. The primary scenario that Build it Beta solves, is the need for developers to deploy applications to testers so that they can provide feedback. It does this by leveraging the enterprise deployment capabilities of the Windows platform, where applications can be signed using a enterprise signing certificate and then deployed to devices that trust that certificate.

Supported platforms

The following Windows platforms are supported by Build it Beta for the installation of test applications.

Windows Phone 8.0
Windows Phone 8.1
Windows 8.1
Windows 10 (Phone and desktop)

Supported application platforms

Applications targeting the following platforms are supported by Build it Beta

Windows Phone 7.x (XAP)*
Windows Phone 8.0 (XAP)
Windows Phone 8.1 (XAP)
Windows Phone 8.1 (APPX)
Windows 8.0 (APPX)*
Windows 8.1 (APPX)
Windows 10 UAP (APPX)

*Build it Beta supports signing and deploying applications targeting Windows Phone 7.x and Windows 8.0. However, due to lack of enterprise distribution support in Windows Phone 7.x there is no way to deploy applications to those devices. Windows Phone 7.x applications can only be tested on Windows Phone 8+ devices. The Windows version of Build it Beta targets Windows 8.1 so there is no support for deploying to Windows 8.0 devices. Windows 8.0 applications need to be tested on Windows 8.1+.

Here are some useful links for getting started with Build it Beta

Distribution of Application for the Windows Platform for Testing

Last year I wrote an article for Visual Studio Magazine entitled Enterprise Distribution of Windows Phone Applications which looks at the requirements and steps required to deploy Windows Phone applications. The process for distributing Windows desktop/slate applications is slightly different but essentially involves signing the appx with an appropriate code signing certificate that is trusted by those computers that the application will be distributed to. We’re using these same techniques with Build it Beta to help developers distribute their applications for testing. Recently we’ve done a number of bug fixes and improvements and now have support for Windows Phone 8.0,  Windows Phone 8.1 (Silverlight), Windows Phone 8.1 (Appx), Windows 8.0 and 8.1, and now Windows 10 applications. There is still a bit of work to go in rounding off some of the rough edges but we’re really keen for developers to start using it.

We’ve also just created a new Build it Beta blog where we will be posting a series of post talking about distribution of applications for testing both in the generic sense (covering signing and enterprise distribution) and of course how Build it Beta works. Don’t forget you can follow Build it Beta on Twitter as well.

Microsoft Continues the Integration Between Blend and Visual Studio

Years after Microsoft attempted to lure designers into the world of app development by giving them a tool where they could assist with the designing of applications, it appears that Microsoft still recognises that design and development, whilst different roles, go hand in hand as part of the development process. In Visual Studio 2015 the integration between Visual Studio and Blend for Visual Studio becomes even more apparent. The changes range from the simple things, like the link to open Blend from within Visual Studio being renamed to “Design in Blend,” through to intellisense in the XAML editor in Blend and better alignment of the various tool windows.

image

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.

Windows 10 Jumpstart Training

Whenever I try to locate the jumpstart training for the Windows 10 Developer Preview tools it always seems to take longer than expected. Anyhow, I thought I’d re-post the direct links to each of the sessions here so that at least I can find them easily next time:

Developer's Guide to Windows 10 Preview- (01) Getting Started

Developer's Guide to Windows 10 Preview- (02) Start Simple- Hello World

Developer's Guide to Windows 10 Preview- (03) Migrating 8.1 Apps to Windows 10

Developer's Guide to Windows 10 Preview- (04) Extension SDKs

Developer's Guide to Windows 10 Preview- (05) SplitView Control

Developer's Guide to Windows 10 Preview- (06) Maps

Developer's Guide to Windows 10 Preview- (07) Pen & Ink

Developer's Guide to Windows 10 Preview- (08) RelativePanel Control

Developer's Guide to Windows 10 Preview- (09) Adaptive Triggers

Developer's Guide to Windows 10 Preview- (10) App-to-App Communication

Developer's Guide to Windows 10 Preview- (11) New XAML Controls and XAML Transform 3D

Developer's Guide to Windows 10 Preview- (12) App Services

Developer's Guide to Windows 10 Preview- (13) Action Center

Developer's Guide to Windows 10 Preview- (14) Evolving the Web Platform

Unable to Activate Windows Store App

I was running up one of our Windows 10 projects today and I encountered a somewhat cryptic error stating that Visual Studio was “Unable to activate Windows Store app…. The … process started, but the activation request failed with the error ‘The app didn’t start’”.

image

I figured there would be more information in the event log but this was not the case, with only this same message appearing there. Luckily it turns out that this issue isn’t specific to Windows 10 applications, and it was in fact this post that clued me on to removing the somewhat unnecessary app.config file that was still in my solution structure. Removing this file worked an absolute treat, although I can’t seem to work out why it fails since Visual Studio does sometimes warn about multiple versions of an assembly being referenced.

Package Manifest for Windows 10

As the tools for Windows 10 applications are still in preview there are some limitations and some features that aren’t quite ready yet. One of these is the designer for the package.manifest file, so the question is how do you know what elements can go in the manifest file. The manifest file is validated using a number of .xsd files that exist in the folder C:\Program Files (x86)\Windows Kits\8.2\Include\10.0.10030.0\winrt

image

These include the various namespaces defined at the beginning of the package.manifest file:

xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap=http://schemas.microsoft.com/appx/manifest/uap/windows10

Disabling the Pinch-Zoom behaviour of the WebBrowser control on Windows Phone

This is an issue that seems to keep coming back to haunt us on various projects where we have to embed web content within a Windows Phone application. One of the best solutions is to modify the CSS of the page being displayed to disable the touch behaviour using the –ms-touch-action (noted that whilst in IE11+ the recommendation is to use the touch-action property but for WP the vendor prefix is still required).

One of the team that I work with came across a post by Colin Eberhardt that handles some of the manipulation events in the visual tree surrounding the actual web content, thereby disabling the pinch-to-zoom behaviour. This technique makes use of Linq to XAML/Visual Tree which is also worth a read

Fix Login Failures to Azure Mobile Services with Enhanced Users Features for Javascript Backends

One of the applications that we’ve been working on that leverages the older javascript backend version of Azure Mobile services was seeing some cases where users couldn’t login. For a while we put it down to incidental issues with our application but we then detected a pattern where it was related to Microsoft Accounts that belonged to one of the domains associated with outlook.com (eg live.com, outlook.com, outlook.com.au, hotmail.com). I don’t know exactly which domains it does affect, nor whether it was all email addresses on those domains. However, what I do know is that in order to fix the issue we had to follow the instructions that Carlos had posted a while ago on the Enhanced Users Feature. We hadn’t done this previously as I wasn’t confident that it wouldn’t break our production application but it turns out the only change we needed to do, as per his instructions, was change to use the asynchronous getIdentities method (which is also an update we were supposed to do a while ago!).