【发布时间】:2018-06-22 15:04:20
【问题描述】:
当我尝试使用 await CrossMedia.Current.TakePhotAsync() 打开相机时,我遇到了异常。它不会在应用程序中打开任何相机。
商店
InterpretedSystem.Runtime.CompilerServices.IAsyncStateMachineVT.<>7__wrap2字段溢出
我的代码如下,
public UserProfilePage()
{
InitializeComponent();
CameraButton.Clicked += CameraButton_Clicked;
BindingContext = new UserProfileViewModel(this.Navigation);
}
private async void CameraButton_Clicked(object sender, EventArgs e)
{
if (CrossMedia.Current.IsCameraAvailable && CrossMedia.Current.IsTakePhotoSupported)
{
// Supply media options for saving our photo after it's taken.
var mediaOptions = new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "Receipts",
Name = $"{DateTime.UtcNow}.jpg"
};
// Take a photo of the business receipt.
try
{
var file = await CrossMedia.Current.TakePhotoAsync(mediaOptions);
}
catch (Exception exception)
{
Console.WriteLine(exception);
throw;
}
}
}
Xaml 页面如下,
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image x:Name="PhotoImage" />
<Button x:Name="CameraButton" Text="Take Photo" Grid.Row="1" />
</Grid>
如何打开我的相机并在 xamarin 中拍照。以下是混淆,
Xam.Plugin.Media = v3.1.2
Xamarin.Forms = v2.5.0.121934
VS2017
【问题讨论】:
-
您找到解决方案了吗?我在使用 Xamarin 广告身份验证时遇到了类似的问题:商店
InterpretedSystem.Runtime.CompilerServices.IAsyncStateMachineVT.extraQueryParameters上的字段溢出。 -
您是否在尝试使用 Xamarin Live 播放器?还是实际的物理设备?
-
正在尝试使用 Xamarin Live Player。切换到物理设备并开始工作。
标签: c# xamarin xamarin.forms xamarin.android