Does ApiInformation not respect the app target version

Viewed 251

Imagine the following setup:

UWP Library:
MinVersion: 10240
TargetVersion: 16299

This library checks at runtime if the UniversalApiContract Version 5 is present.
If yes, it will use the new NavigationView control that.

UWP App:
MinVersion: 10240
TargetVersion: 10240

This app references the UWP Library project.
When I run this app on my Computer, which has Windows 10 Version 16299 installed, the following happens:
The UWP Library checks at runtime for the api contract. As I have the newest version of Windows 10, yes it is present.
Then it tries to create the NavigationView control, and I get a TypeLoadException with the message Could not find Windows Runtime type 'Windows.UI.Xaml.Controls.NavigationView'.

What? Why? Does the ApiInformation class not respect the target version of the running app?

What can I do to work around this issue?
I thought ApiInformation was the way to avoid this, but apparently not?!

Here is a Github repository showcasing the error:
https://github.com/haefele/ApiInformationTargetVersionFail

If you set the target-version of the MyApp project to 16299, everything works fine.

1 Answers
Related