I have tried as described in this post (https://blogs.windows.com/buildingapps/2017/01/25/calling-windows-10-apis-desktop-application/#PdHk3f4QeTSsSvWy.97) to determine the position with the class Geolocator. It works fine when I add a reference to C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0\Windows.winmd instead of C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd. But I get an exception when I use the method GetFileAsync in the following code
static async void LoadVoiceCommands()
{
try
{
StorageFile storageFile = await Package.Current.InstalledLocation.GetFileAsync("CustomVoiceCommandDefinitions.xml");
await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
The exception says The process has no package identity. (Exception from HRESULT: 0x80073D54)
I call the method LoadVoiceCommands in MainWindow constructor after InitializeComponent
When I add reference C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd instead of C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0\Windows.winmd and use namespaces like:
using Windows.ApplicationModel; using Windows.Storage; using Windows.Devices.Geolocation;
there is than an error CS0731 The type forwarder for type in assembly 'Windows' causes a cycle
for the line
await locator.GetGeopositionAsync();
and
await Package.Current.InstalledLocation.GetFileAsync("CustomVoiceCommandDefinitions.xml");
Any ideas on how to solve this? I could not find a solution in google