There is one problem that I encountered by following the post. I was dynamically detecting for UniversalApiContract v4. However, when the code was running on .NET 4.5 classic desktop app (manifested for Windows 10 Runtime), there was an exception about “Windows
Runtime-type XXXXX is not found”.
Turned out that the when inlining the contract-specific call in the IF that checks for contract presence, then it will throw exception.
So, the following is WRONG:
public void DoContractSpecificStuff()
{
if(ApiInformation.IsApiContractPresent(“Windows.Foundation.UniversalApiContract”, 4))
{
GattCharacteristicsResult gatt = … Do some v4 stuff with GattCharacteristicsResult
}
else
{ /* Do <v4 stuff*/ }
}
It needs to be coded in the following way instead:
public void DoContractSpecificStuff()
{
if(ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4))
{
DoContractV4Call();
}
else
{ /* Do <v4 stuff*/ }
}
public void DoContractV4Call()
{
GattCharacteristicsResult using code goes here
}