我正在尝试使用带有 DependencyInjection 的 iOS 代码从 Xamarin Forms 应用程序发送电子邮件,如下所示:
[assembly: Xamarin.Forms.Dependency(typeof(SendMail))]
namespace SampleApp.iOS.PlatformSpecific
{
public class SendMail : ISendMail
{
public void SendMail()
{
Device.BeginInvokeOnMainThread(() =>
{
if (MFMailComposeViewController.CanSendMail) <-- crashes here
{
// my code
}
}
}
}
}
上面指示的行在真实设备上总是崩溃(但在模拟器上有效)。崩溃如下:
=================================================================
Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
有什么想法可能出问题了吗?