我正在尝试使用.net核心在树莓派上运行以下c#代码,该代码在Windows上可以正常运行,并且完全可以实现我想要的功能。但是在pi上,这给了我一个涉及kerberos的奇怪例外。过去,我曾使用此pi运行其他.net核心程序。
我的代码是:
using System;
using Microsoft.Exchange.WebServices.Data;
namespace Test
{
class Program
{
static void Main(string[] args)
{
// Create the binding to ews
ExchangeService service = new ExchangeService();
// Set the credentials for the user
service.Credentials = new WebCredentials("user@email.com", "password");
// Set the URL
service.Url = new Uri("https://email.com/ews/Exchange.asmx");
// Create a bew email
EmailMessage email = new EmailMessage(service);
// Set the recipiant to an email
email.ToRecipients.Add("user@email.com");
// Set the subject
email.Subject = "HelloWorld";
// Set the body
email.Body = new MessageBody("This is the first email I've sent by using the EWS Managed API.");
email.Send();
}
}
}
但是,当我使用dotnet core将其发布到linux-arm并在pi上运行时,出现以下异常
Unhandled Exception: System.ComponentModel.Win32Exception: GSSAPI operation failed with error - An invalid status code was supplied (Cannot find KDC for realm "email.com").
at System.Net.HttpWebRequest.GetResponse()
at
Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse()
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
at Microsoft.Exchange.WebServices.Data.EmailMessage.Send()
at Test.Program.Main(String[] args) in V:\visual studio stuff\Test\Test\Test\Program.cs:line 23
任何帮助都会很棒