如何解决"'IAsyncActionWithProgress<>'在未引用的程序集中定义";在 Windows UAP 应用程序中 [英] How to resolve " 'IAsyncActionWithProgress<>' is defined in an assembly that is not referenced" in Windows UAP app

查看:16
本文介绍了如何解决"'IAsyncActionWithProgress<>'在未引用的程序集中定义";在 Windows UAP 应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

解决方案

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.

这篇关于如何解决"'IAsyncActionWithProgress&lt;&gt;'在未引用的程序集中定义";在 Windows UAP 应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆