Xamarin.Essentials 屏幕截图无法在 Android 上运行
Xamarin.Essentials Screenshot not working on Android
我正在按照文档:https://docs.microsoft.com/en-us/xamarin/essentials/screenshot 截取屏幕截图并将其保存到 MemoryStream
然后将其用作“图像测试”的图像源(单击按钮。下面是我的代码对于 CaptureScreenshot()
功能,在 Android 10 设备上执行按钮单击时出现以下错误。我是 运行 最新版本的 Xamarin.Essentials 和 Xamarin.Forms.
函数:
private async void CaptureScreenshot(object sender, EventArgs e)
{
var screenshot = await Screenshot.CaptureAsync();
var stream = await screenshot.OpenReadAsync();
var array_image = ImageSource.FromStream(() => stream);
imagetest.Source = array_image;
}
错误:
"System.TypeLoadException
Message=Could not load type of field 'Order_Form_V1.CustomArrayConfiguration+d__3:5__2' (6) due to: Could not resolve type with token 01000029 from typeref (expected class 'Xamarin.Essentials.ScreenshotResult' in assembly 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Xamarin.Essentials.ScreenshotResult member:(null)"
感谢我能得到的任何意见。
您可以尝试清理解决方案并删除所有bin和obj文件夹,然后重建 检查它是否有效。
Xamarin 表单:5.0.0.1874
Xamarin 基础:1.6.0
Visual Studio : 16.8.4
我正在按照文档:https://docs.microsoft.com/en-us/xamarin/essentials/screenshot 截取屏幕截图并将其保存到 MemoryStream
然后将其用作“图像测试”的图像源(单击按钮。下面是我的代码对于 CaptureScreenshot()
功能,在 Android 10 设备上执行按钮单击时出现以下错误。我是 运行 最新版本的 Xamarin.Essentials 和 Xamarin.Forms.
函数:
private async void CaptureScreenshot(object sender, EventArgs e)
{
var screenshot = await Screenshot.CaptureAsync();
var stream = await screenshot.OpenReadAsync();
var array_image = ImageSource.FromStream(() => stream);
imagetest.Source = array_image;
}
错误:
"System.TypeLoadException Message=Could not load type of field 'Order_Form_V1.CustomArrayConfiguration+d__3:5__2' (6) due to: Could not resolve type with token 01000029 from typeref (expected class 'Xamarin.Essentials.ScreenshotResult' in assembly 'Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:Xamarin.Essentials.ScreenshotResult member:(null)"
感谢我能得到的任何意见。
您可以尝试清理解决方案并删除所有bin和obj文件夹,然后重建 检查它是否有效。
Xamarin 表单:5.0.0.1874
Xamarin 基础:1.6.0
Visual Studio : 16.8.4