4

I have a WPF application which utilizes a handwriting control.

By using an

<InkCanvas></InkCanvas>

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.

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.

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

or

Windows.Foundation.Metadata.Platform.WindowsPhone

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

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.

Neil.Allen
  • 1,606
  • 1
  • 15
  • 20
  • Take a look at this post: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. Note that these APIs are only available for Windows 8, so even you manage to get this working, your desktop app will not work in other OSes. – yms Nov 25 '13 at 17:51
  • Hi, did you find a solution to your problem ? Before I was using WinRT API from desktop app by following some tutorials. But now, when I change the to 8.1 I have the same problem as you. Thanks. – gurvanhenry Dec 10 '13 at 10:47

1 Answers1

2

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

Windows.UI.Input.Inking

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. 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

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.

Neil.Allen
  • 1,606
  • 1
  • 15
  • 20