I am trying to create a UWP project With VS 2017 and MVVMLight tageting Windows 10 version 1803 to 1809. It is a WPF application.
After some days of work, my solution compile and execute correctly and my main view display correctly. Now, I need to add support for a StorageDevice and VS suggest to add a reference to Windows.winmd. Now, StorageDevice is recognized but this add conflicts message and build errors.
The conflicts are all with Windows.Foundation.UniversalApiContract v7.0.0.0 for different classes including
I have many years of experience in desktop apps, but I admit I am a rookie in UWP. I try to grasp the concept, but in my point of view, it changes year after year and I don't understand the interrelation between all the components and the concept of winmd. So, I am lost and don't see any solution path or similar problem solution with google.
To reproduce the problem :
public App()
{
InitializeComponent();
Suspending += OnSuspending;
StorageFolder x = StorageDevice.FromId("");
}
Add usings for the following namespaces :
Compile. It will show an error for the line added in point 2 and suggest to add a reference to Windows.winmd. StorageDevice is defined in the Windows.Devices.Portable namespace.
Erreur CS0433 Le type 'ApplicationExecutionState' existe dans 'Windows.Foundation.UniversalApiContract, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' et 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' MvvmLight2 D:\Code\App.xaml.cs 41 Actif
Translated to english :
Error CS0433 The type 'ApplicationExecutionState' exist in 'Windows.Foundation.UniversalApiContract, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' MvvmLight2 D:\Code\App.xaml.cs 41 Actif
StorageDevice is included in Windows Desktop Extension SDK, you do not need to add reference to Windows.winmd.
Follow the steps to add reference to 'Windows Desktop Extension':
Right click the 'Reference' of your project -> Add Reference -> Universal Windows -> Extensions -> Windows Desktop Extensions for the UWP .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.