WPF应用程序整合WinAPI的(Win8的)组件 [英] WPF Application Incorporating WinAPI (Win8) components

查看:399
本文介绍了WPF应用程序整合WinAPI的(Win8的)组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,它利用手写控制。

I have a WPF application which utilizes a handwriting control.

通过使用

<InkCanvas></InkCanvas>

在我的XAML中,我能得到用户的笔触,并使用InkAnalysis把它们变成文字类。然而,这是严格的32位,和我的要求需要一个64位版本。

In my XAML, I was able to get the user's strokes, and turn them into text using the InkAnalysis class. However, this is strictly 32bit, and my requirements dictate a 64bit build.

无法找到64位兼容库,我看着升级到.NET 4.5和利用的Windows8其中的类可用于桌面应用程序(通过还增加了
< TargetPlatformVersion> 8.1< / TargetPlatformVersion>到了的csproj文件,这样我可以添加Windows的命名空间引用)。幸运的是,Windows.UI.Input.Inking是

Unable to find a 64bit compatible library, I looked into upgrading to .NET 4.5 and utilizing the Windows8 classes which are available to desktop apps (by also adding <TargetPlatformVersion>8.1</TargetPlatformVersion> to the csproj file so that I could add the 'Windows' namespace references). Luckily, Windows.UI.Input.Inking is.

然而,当我添加引用Windows.UI.Input.Inking,我得到它规定一个生成错误:

However, when I add the reference to Windows.UI.Input.Inking, I get a build error which states:

Unknown build error, 'Cannot resolve dependency to Windows Runtime type 'Windows.Foundation.Metadata.PlatformAttribute'. When using the ReflectionOnly APIs, dependent Windows Runtime assemblies must be resolved on demand through the ReflectionOnlyNamespaceResolve event.'



我特地到:

I have looked into the:

Windows.Foundation.Metadata.PlatformAttribute

和它似乎想枚举成员,或者:

And it seems to want an enum member, either:

Windows.Foundation.Metadata.Platform.Windows

Windows.Foundation.Metadata.Platform.WindowsPhone

这是一个桌面应用程序,所以我会很明显选择定位Platform.Windows,但无法弄清楚如何告诉编译器这一点。

This is a desktop application, so I would obviously choose to target Platform.Windows, but cannot figure out how to tell the compiler this.

我怎样才能将这一Windows.UI.Input.Inking级到我的WPF应用程序?我的最终目标很简单,就是招从inkcanvas到文本转换,在64位环境。

How can I incorporate this Windows.UI.Input.Inking class into my WPF application? My end goal is simply to convert strokes from the inkcanvas into text, in a 64 bit environment.

推荐答案

我发现我收到此错误是由于加到参考:

I discovered that I was receiving this error due to the reference added to the:

Windows.UI.Input.Inking

库。看来,添加引用到Windows 8 / 8.1 WinAPI的组成部分(从非WinAPI的应用程序)的正确方法如下:

library. It seems that the correct way to add reference to Windows 8/8.1 WinAPI components (from a non WinAPI application) is the following:


  1. 添加< TargetPlatformVersion> 8.1< / TargetPlatformVersion> 到的csproj文件

  2. 添加参照窗口库(这是关键 - 添加特定的lib,在这种情况下, Windows.UI.Input.Inking ,使生成错误)

  3. 添加更具体的(例如: Windows.UI.Input.Inking )的实际文件引用其中所需的API

  1. Add <TargetPlatformVersion>8.1</TargetPlatformVersion> to the csproj file
  2. Add reference to the Windows library (this is the key - adding the specific lib, in this case, Windows.UI.Input.Inking, causes the build error)
  3. Add the more specific (ex: Windows.UI.Input.Inking) reference in the actual file where the API is required

我在创建的NuGet包,其中将编辑的csproj文件,并添加窗口引用。如果/结束时,我会更新这个。

I am working on creating a NuGet package which will edit the csproj file, and add the Windows reference. I'll update this if/when it is completed.

这篇关于WPF应用程序整合WinAPI的(Win8的)组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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