与API的LockScreen桌面使用WinRT的 [英] Using WinRT on the Desktop with LockScreen API

查看:104
本文介绍了与API的LockScreen桌面使用WinRT的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个玩具的桌面应用程序,交互的的LockScreen API,这是的WinRT和用途异步/的await 。按照指示后,<一个href=\"http://blogs.msdn.com/b/eternalcoding/archive/2013/10/29/how-to-use-specific-winrt-api-from-desktop-apps-capturing-a-photo-using-your-webcam-into-a-wpf-app.aspx\"相对=nofollow>这里,我已经启用支持WinRT中,并添加以下参考资料:

  System.Runtime.dll
System.Runtime.WindowsRuntime.dll
System.Runtime.InteropServices.WindowsRuntime.dll

不过,我仍然得到这个错误,而建设:

'System.Runtime.CompilerServices.TaskAwaiter'不包含定义'IsCompleted

该错误与相关联的await 我的code线。还有什么我缺少什么?

编辑:这是有问题的code和项目引用的完整列表。

 使用系统;
使用System.Windows.Forms的;
使用System.Drawing中;
使用System.Runtime.InteropServices;
使用Windows.System.UserProfile;
使用System.IO;
使用Windows.Storage.Streams;公共类节目:表单
{
    [STAThread]
    静态无效的主要()
    {
        ...
    }    公共项目()
    {
        串壁纸= ...
        ...        SetLockScreenImage(墙纸);
    }    私人异步无效SetLockScreenImage(字符串路径)
    {
        InMemoryRandomAccessStream RAS =新InMemoryRandomAccessStream();
        ...        等待LockScreen.SetImageStreamAsync(RAS);
    }
}

引用

  Microsoft.CSharp
系统
System.Core程序
System.Data这
System.Data.DataSetExtension
System.Deployment
System.Drawing中
System.Runtime
System.Runtime.InteropServices.WindowsRuntime
System.Runtime.WindowsRuntime
System.Windows.Forms的
的System.Xml
System.Xml.Linq的
视窗


解决方案

我发现,64位PC上的目标平台设置为64可以解决这个问题。在<一个开发商href=\"http://social.msdn.microsoft.com/Forums/en-US/4df4323b-35cb-4816-b01c-082312109931/win8-desktop-app-use-lockscrrengetimagestream-problem?forum=windowsgeneraldevelopmentissues\"相对=nofollow>这个MSDN论坛主题解决了因为你是有类似的问题,虽然Windows 8的消费者preVIEW,所以很难说,如果解决方案仍然有效。

I'm writing a toy desktop app that interacts the LockScreen API, which is part of WinRT and uses async/await. After following the instructions here, I've enabled support for WinRT and added the following references:

System.Runtime.dll
System.Runtime.WindowsRuntime.dll
System.Runtime.InteropServices.WindowsRuntime.dll

However I still get this error while building:

'System.Runtime.CompilerServices.TaskAwaiter' does not contain a definition for 'IsCompleted'

The error is associated with the await line of my code. What else am I missing?

Edit: Here's the code in question and the full list of references for the project.

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using Windows.System.UserProfile;
using System.IO;
using Windows.Storage.Streams;

public class Program : Form
{
    [STAThread]
    static void Main()
    {
        ...
    }

    public Program()
    {
        string wallpaper = ...
        ...

        SetLockScreenImage(wallpaper);
    }

    private async void SetLockScreenImage(string path)
    {
        InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
        ...

        await LockScreen.SetImageStreamAsync(ras);
    }
}

References

Microsoft.CSharp
System
System.Core
System.Data
System.Data.DataSetExtension
System.Deployment
System.Drawing
System.Runtime
System.Runtime.InteropServices.WindowsRuntime
System.Runtime.WindowsRuntime
System.Windows.Forms
System.Xml
System.Xml.Linq
Windows

解决方案

I have found that setting target platform to x64 on 64-bit PC could resolve the issue. Developers on this MSDN forum thread were solving a similar problem as you are having, although for Windows 8 Consumer Preview, so it is hard to tell, if the solution is still valid.

这篇关于与API的LockScreen桌面使用WinRT的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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