6

I am developing a Windows UAP app in Visual Studio Ultimate CTP 2015 (latest one available in site).

I am facing issues while using await on Functions returning IAsyncActionWithProgress<>, IAsyncAction<> , IAsyncOperation<> and IAsyncOperationWithProgress<>.

I am getting the following error

Error CS0012 The type 'IAsyncActionWithProgress<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

I tried adding reference to the assembly mentioned (Windows). Even though this resolved the above error, it created another error at many other places (seems like there is a repetition of some classes/API's in both the assemblies. One of the error obtained is :

Error CS0433 The type 'Page' exists in both 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

Example of code

Windows.Storage.FileProperties.BasicProperties fileSize = await file.GetBasicPropertiesAsync();

This was working fine for a Windows Phone 8.1 app in Visual Studio 2013. What is the change I have to make to get the same result in UAP App in Visual Studio 2015.

svick
  • 236,525
  • 50
  • 385
  • 514

4 Answers4

3

I had the same problem with the IAsyncAction and I have just managed to solve it, so I am going to share the (maybe not the best) solution.

First I tried repair VS, no success. Then reinstalling VS, again no success. So I went to control panel -> programs -> uninstall programs, and from there I uninstalled everything that had something to do with Visual Studio or .NET. It displayed me a couple of errors, like that some applications require this program to run, but i anyway uninstalled it (if I will need it I will install it again). After that I installed Visual Studio again, wrote the code which caused the error and, it worked, with no error.

Hope this helps you as it did help me.

  • This worked for me, thanks Jakub. To flush it out a little more I: 1. Uninstalled VS 2. Uninstalled all Windows SDK 3. Deleted C:\Program Files (x86)\Windows Kits\10 4. Reinstalled VS 2017 and allowed it to install my Windows SDK – Lee Richardson May 23 '17 at 01:44
1

Sounds to me like your migration from Windows 8.1 to Windows 10 didn't go through quite right. Andy Wigley has a video with instructions on how to migrate a Windows 8.1 project to Windows 10. His example is for Phone but also applies to desktop. Here's the video: http://www.microsoftvirtualacademy.com/training-courses/a-developers-guide-to-windows-10-preview. Go look at the section titled "Migrating 8.1 Apps to Windows 10".

To be clear, you shouldn't need to add any references to get those types working in a Windows 10 Universal App. A good starting point (on Andy also points out in his video) is to create a new black Windows 10 Universal App project and compare your project and package manifest files to it and just bring over the changes.

  • I actually didn't migrate from Windows 8.1 to UAP. I created a new project in UAP and Copied all my code into the new UAP project, so that I don't want to play with package manifest and other project related files – Jose John Thottungal Apr 20 '15 at 04:52
  • @JoseJohnThottungal My guess would be that your VS install got borked. I know it's a lot to ask but you might want to uninstall: Windows 10 Tools and Visual Studio 2015 (two separate things in the Add/Remove Programs applet in Control Panel). Then restart and reinstall. It is pre-release software so this sort of thing does happen unfortunately. Alternatively, wait till [Build](http://www.buildwindows.com) when the new SDK and tools drop before you do this. Again, sorry about your subpar experience with this :( – aruntalkstech Apr 27 '15 at 05:58
0

I think the issue is the following, you can deploy on the Windows Phone but when you try to access to specific functions of the Phone you need to add enter image description here

Juan Pablo Garcia Coello
  • 3,192
  • 1
  • 23
  • 33
0

Looks like changing Project -> Properties -> Library -> Min version from any version below 14393 to 14393 or above helps with the issue.

enter image description here

enter image description here

a''
  • 2,322
  • 2
  • 23
  • 34