我正在为使用Speech API的Windows 10创建一个UWP应用程序但是在编译时我遇到了一个奇怪的错误.
场景是这样的:
针对Windows 8.1的PCL项目(当我创建项目时,我将Windows 10设置为目标但Visual Studio降级到Windows 8.1,因为"它们支持相同的可移植API集")并引用了"Windows.Foundation.UniversalApiContract"因为它包含Speech API(Windows.Media.SpeechRecognition和Windows.Media.SpeechSynthesis).
参考PCL项目的UWP应用程序.UWP不使用Speech API,我只在PCL项目上使用它.
PCL项目已成功构建,但是当我构建UWP项目时,会出现很多错误,例如".winmd文件'Windows.Foundation.UniversalApiContract.winmd'包含类型'XXXXX'.保留使用Windows命名空间." 我认为错误是由PCL项目的引用引起的.
我尝试直接从UWP应用程序调用Speech API,它似乎工作,但我不喜欢它,因为我更喜欢在其他库项目中使用应用程序逻辑,以防我将应用程序移植到其他平台.
我不知道该怎么办.如果PCL的目标是Windows 8.1,我必须能够使用Speech API而不需要像在UWP项目中那样添加引用,不是吗?是否有任何解决方法强制PCL仅针对Windows 10?我错了,我应该使用其他项目类型而不是PCL?
我正在使用WriteableBitmapEx库编辑使用Windows 8 Pro平板电脑的凸轮拍摄的图像。每次调用GetPixel()函数时,都会得到一个AccessViolationException,这是代码:
Windows.Media.Capture.MediaCapture captureMgr = new MediaCapture();
await captureMgr.InitializeAsync();
IRandomAccessStream memoryStream = new InMemoryRandomAccessStream();
await captureMgr.CapturePhotoToStreamAsync(imageProperties, memoryStream);
await memoryStream.FlushAsync();
memoryStream.Seek(0);
WriteableBitmap tmpImage = new WriteableBitmap(1, 1);
tmpImage.SetSource(memoryStream);
tmpImage.GetPixel(1, 1); // An AccessViolationException occurs.
Run Code Online (Sandbox Code Playgroud)
我做错了什么?