2
votes

I am starting my first Xamarin Forms application using Visual Studio 2015. The default template provided 6 Project. (Android,iOS,PCL,UWP,8.1,windows phone).

All the projects works correctly including the Android,8.1,Windows Phone Emulator.

But when i try to deploy the UWP project , breaks (Exception) at the first statement where it calls the MainPage inside PCL. This happens in both Local Machine and Emulator. (debug Mode , All CPU).

I have already updated xamarin forms to the latest stable release, updated Visual Studio but i am not able to resolve the issue.

Exception:

An exception of type 'System.TypeLoadException' occurred in Xamarin.Forms.Platform.UAP.dll but was not handled in user code

Additional information: Could not find Windows Runtime type 'Windows.UI.ViewManagement.StatusBar'.

Please Help

3

3 Answers

4
votes

The Windows.UI.ViewManagement.StatusBar is a type that is only available in the Windows Mobile Extension SDK and you have to reference this SDK for it to be available.

Right-click your UWP project in the Solution Explorer, select Add -> Reference, then under Universal Windows select Extensions and find Windows Mobile Extensions for the UWP. Check the one that matches the targeted Windows 10 build version of your app.

You also need to use the IsTypePresent API, which will check at runtime if the type is available on the current device. This is important, because StatusBar does not exist on any other version of Windows 10 than on Mobile:

if(ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") )
{
   //your code
}
0
votes

Look like issue in xamarin UWP concept , are you updated Xamain.Forms ? Goto Tools-> NuGet Package manager -> Manage Package for Solution -> Microsoft.NETCore.Universal Windows Platform -> update latest version.

after updated all , still same problem please check here some around https://forums.xamarin.com/discussion/64731/how-to-solve-unknown-type-in-uwp-app-windows-ui-viewmanagement-statusbar

0
votes

If none of this work try updating your windows SDK to the latest version. It worked for me. I also added the reference to Windows Mobile Extensions for the UWP.

EDIT:

I also have experimented that sometimes when you update visual studio it fails again. I had to manually change de SDK version in my UWP project, going to Properties > Application > Target Version > Select latest version