如何解决此“缺少程序集引用"错误? [英] How to fix this 'Missing assembly reference' error?

查看:379
本文介绍了如何解决此“缺少程序集引用"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 Wacom Bamboo Slate 捕获画布上实时笔触的应用程序.该应用程序正在使用C#为UWP平台开发.在画布上绘制后,将实现保存功能.我正在使用供我参考.下面是代码和错误消息:

I am working on an application that captures real time pen strokes on a canvas using Wacom Bamboo Slate. The application is being developed for UWP platform using C#. After drawing on the canvas, save feature is to be implemented. I am using this for my reference. Below is the code and error message:

private async void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StorageFolder storageFolder = KnownFolders.SavedPictures;
            var file = await storageFolder.CreateFileAsync("sample.jpg", CreationCollisionOption.ReplaceExisting);

            CanvasDevice device = CanvasDevice.GetSharedDevice();
            CanvasRenderTarget renderTarget = new CanvasRenderTarget(device, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight, 96);

            using (var ds = renderTarget.CreateDrawingSession())
            {
                ds.Clear(Colors.White);
                ds.DrawInk(inkCanvas.InkPresenter.StrokeContainer.GetStrokes());
            }

            using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                await renderTarget.SaveAsync(fileStream, CanvasBitmapFileFormat.Jpeg, 1f);
            }
        }

CS1061'InkCanvas'不包含InkPresenter的定义,并且找不到可访问的扩展方法InkPresenter接受类型为InkCanvas的第一个参数(您是否缺少using指令或程序集引用?)

CS1061 'InkCanvas' does not contain a definition for InkPresenter and no accessible extension method InkPresenter accepting a first argument of type InkCanvas could be found (are you missing a using directive or an assembly reference?)

推荐答案

上面提到的示例可以找到此处.

The sample referred above can be found here.

该示例使用Microsoft软件包Win2D.UWP(版本1.6.0)的Microsoft.Graphics.Canvas命名空间部分中的CanvasDevice. UWP项目样本目标针对Windows 10的内部版本10240(最低10240).

The sample use CanvasDevice from the Microsoft.Graphics.Canvas namespace part of the package Win2D.UWP (version 1.6.0) from Microsoft. The UWP project sample targets build 10240 (minimum 10240) of Windows 10.

可以安装软件包Win2D.UWP

  • 使用菜单项目>管理Nuget程序包",或
  • 通过在"Solution Explorer"的UWP项目中选择上下文菜单"References"来
  • .

  • using the menu "Project > Manage Nuget Packages", or
  • by selecting the context menu "References" in the UWP project of "Solution Explorer".

  1. 选择已安装"并卸载当前的2d图形渲染包(如果有).
  2. 选择浏览",查找Win2D.UWP并从Microsoft安装.
  1. Select "Installed" and uninstall the current 2d graphics rendering package, if any.
  2. Select "Browse", look for Win2D.UWP and install the one from Microsoft.

请注意,最新版本的Win2D.UWP更新于5/17/2018 1.23.0版,要求目标平台为17134.

Please note that the latest version of Win2D.UWP updated 5/17/2018 version 1.23.0 requires target platform to be 17134.

例如,在UWP项目属性中使用Win2D.UWP版本1.23和目标版本设置为10240的版本构建后,错误列表"可能会显示以下错误消息:

For example, "Error List" might show the following error message after a build with version 1.23 of Win2D.UWP and target version set to 10240 in the UWP project properties:

This version of Win2D requires Windows SDK >= 10.0.17134.0, but TargetPlatformVersion is 10.0.10240.0.  

可以在UWP项目属性中更改目标版本

Target version can be changed in the UWP project properties

  • 选择菜单项目>项目名称属性",或
  • 通过从解决方案资源管理器"中的UWP项目中选择上下文菜单属性".

PS:在MainPage.xaml.cs中的InitializeComponent();之后添加以下内容,以启用具有选择的输入设备类型的绘图:

PS: Add the following after InitializeComponent(); in MainPage.xaml.cs to enable drawing with a selection of input device types:

MyInkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Mouse | CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Touch;

这篇关于如何解决此“缺少程序集引用"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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