-
Migrate your Windows 8 apps from Release Preview to RTM
Here we go again: a new Windows 8 version has been released (luckily, it’s the last one ) and we have to test our application against the RTM, to see if everything is working fine.
Luckily, this time the migration process is much easier than with the Release Preview: I’ve been able to run my applications on the RTM just by compiling them with the final Visual Studio 2012 release; when Release Preview was released, instead, I had to fix a lot of things, since there were a lot of breaking changes from the Consumer Preview.
In this post I would like just two highlight two important things to keep in mind.
Update the manifest file
Thanks to Daniele Bochicchio I’ve found that the Windows 8 manifest file contains a reference to the OS version which the application is compiled for. If you’re working on a project created with the Release Preview, the version number will be 6.2.0, while the RTM version number is 6.2.1. Unlucky, for old projects, Visual Studio doesn’t update it for you, so you need to proceed manually.
- In Visual Studio 2012 right click on the Package.appxmanifest file and choose View code.
- You’ll find a section in the XML file called Prerequisites.</ul>
<Prerequisites> <OSMinVersion>6.2.0</OSMinVersion> <OSMaxVersionTested>6.2.0</OSMaxVersionTested> </Prerequisites>
</pre>
* Change the value **6.2.0** that is stored in both nodes to **6.2.1,** so that it looks like this: <pre class="brush: xml;"><Prerequisites> <OSMinVersion>6.2.1</OSMinVersion> <OSMaxVersionTested>6.2.1</OSMaxVersionTested> </Prerequisites>
</pre>
And you’re done! This way you’ll be able to take benefit of all the WinRT changes applied to the RTM: otherwise, the app will run in a compatibility mode called **Release Preview Compatibility Mode.** You’ll app will pass the certification process anyway, but it’s better if we set from the beginning the right OS version. If you want to go deeper about the RTM changes, take a look at <a href="http://www.microsoft.com/en-us/download/details.aspx?id=30706&WT.mc_id=rss_windows_allproducts%23" target="_blank">this document</a> published by Microsoft that lists all the changes between the RP and the RTM from a developer point of view. ### Unable to activate Windows Store application: the app didn’t start The first time you open your project with Visual Studio 2012 RTM and you try to debug it, you may occur in a strange error: **_Unable to activate Windows Store application. The activation request failed with error ‘The app didn’t start’_** In this case the solution is simple: close Visual Studio, delete the **bin** and **obj** folders inside your project’s folder, open it again with Visual Studio and launch it. This time it will start successfully!
in
- In Visual Studio 2012 right click on the Package.appxmanifest file and choose View code.
-
How to deal with the “Unspecified error” in a Windows Phone application
While developing and testing a Windows Phone application you may have to deal with a really annoying problem: your application crashes and the only error reported by Visual Studio is a generic Unspecified error.
Visual Studio itself isn’t of any help, because the error is intercepted by the global error handler available in the App.xaml.cs file, so you don’t have a way to understand where exactly the problem occured.
The solution is easy to understand, even if it’s not easy to find: this error is raised usually when your XAML contains a property with an invalid value. For example, when I had to deal with this error I found that, by mistake, the Margin property of a control contained the value 0k, 0, 0, 15, that is obviously not correct (the margin property accepts only numeric values).
To help understanding where your application may contain such an error, keep track of the the time when Visual Studio intercept the “Unspecified error” exception: usually, this error is raised only when you navigate towards a page that has this problem.
Good debugging!
in
-
How to open Internet Explorer by code in a Metro style application
Recently I’ve worked on a Windows 8 application to promote my blog: people can use it to read my posts within the application and to be notified (using both toast and tile notifications) every time a new post is published. The application uses a web view to display the detail of a post: the problem came when I had to manage the snapped view, since there isn’t enough space on screen to display a web view.
During the pre certification lab that I’ve attended in Microsoft Italy the trainer gave me a good tip: in case the application is snapped, the post detail should be opened using Internet Explorer and not inside the application. In fact, in this scenario, Internet Explorer will open in filled mode and the user will be able to read the post without any difficulty.
In a Windows Phone application this behavior is easy to implement, thanks to the WebBrowserTask launcher. How to do the same in a Windows 8 application?
My first challenge was to identify the current visual status of the application: I need, in fact, a different behavior according to the visual status. When the application is in “standard” mode I use a GridView to display all the posts: when the user taps on one of them, it should be opened inside the application; when the application, instead, is in snapped mode the GridView is replacted by a ListView: in this scenario when the user taps on one of the posts it should be opened inside Internet Explorer.
For this purpose WinRT features a class called ApplicationView, that is part of the Windows.UI.ViewManagement namespace. This class exposes, as a static object, the Value property, which type is ApplicationViewState: it’s an enumerable, that offers a value for each one of the available visual states (that are Snapped, Filled, FullScreenLandscape and FullScreenPortrait). The value of this property matches the current visual state of the application. This is exactly what I needed to manage the different behavior.
The second step is to find the WebBrowserTask corresponding in the WinRT world: please welcome the Launcher static class, that is part of the namespace Windows.System.Launcher. This classes exposes the method LaunchUriAsync, that does exactly what we need: it opens a new page in the Internet Explorer Metro application, according to the Uri that is passed as parameter.
Here is an example where we apply this code in the SelectionChanged event handler, that is raised every time the user taps on an item of a GridView or a ListView.
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (ApplicationView.Value == ApplicationViewState.Snapped) { Launcher.LaunchUriAsync(new Uri(e.AddedItems[0])); } else { Frame.Navigate(typeof (DetailPage), e.AddedItems[0]); } }
in
subscribe via RSS