Microsoft.Exchange.WebServices.Data.Appointment から派生クラスを作成しようとしています。ただし、シリアル化エラーのように見えるものをスローせずに派生クラスを保存することはできません。これは、派生クラスに変更を加えていない場合でも発生します。
これは機能します:
public void CreateTestAppointment() {
Appointment appointment = new Appointment(Exchange) {
ItemClass = "IPM.Appointment", //Exchange Specific. Dont touch unless you know what this does. I sure as hell don't.
Subject = string.Format("{0} Test", "Oliver")
};
appointment.RequiredAttendees.Add("okane@cottinghambutler.com");
appointment.Body = new MessageBody {
Text = "Meeting invite body text placeholder"
};
//Add item to the appropriate categories
appointment.Categories.Add(string.Format("[C]{0}", "Arbitrary Client Group"));
// Add calendar properties to the appointment.
appointment.Start = DateTime.Now.AddMinutes(10);
appointment.End = DateTime.Now.AddMinutes(30);
appointment.Save(Hc360CallCalendarFolderId, SendInvitationsMode.SendOnlyToAll);
}
しかし、これはしません:
public void CreateTestAppointment() {
InheritedAppointment appointment = new InheritedAppointment(Exchange) {
ItemClass = "IPM.Appointment", //Exchange Specific. Dont touch unless you know what this does. I sure as hell don't.
Subject = string.Format("{0} Test", "Oliver")
};
appointment.RequiredAttendees.Add("okane@cottinghambutler.com");
appointment.Body = new MessageBody {
Text = "Meeting invite body text placeholder"
};
//Add item to the appropriate categories
appointment.Categories.Add(string.Format("[C]{0}", "Arbitrary Client Group"));
// Add calendar properties to the appointment.
appointment.Start = DateTime.Now.AddMinutes(10);
appointment.End = DateTime.Now.AddMinutes(30);
appointment.Save(Hc360CallCalendarFolderId, SendInvitationsMode.SendOnlyToAll);
}
派生クラスで実際に何もしていないので、これは非常に奇妙です。
public class InheritedAppointment : Microsoft.Exchange.WebServices.Data.Appointment {
public InheritedAppointment(ExchangeService serivce)
: base(serivce) {
}}
これは XML にシリアル化されているようで、一部の値は null ですが、それが何であるかを理解することはできません。これが生のエラーです
テスト名: TestMeetingCreation テストのフルネーム: Hc360LibTests.UnitTest1.TestMeetingCreation テスト ソース: c:\Users\okane\Documents\Visual Studio 2012\Projects\HealthCheck360OutlookCallScheduleHelper\Hc360LibTests\UnitTest1.cs: 15 行目 テスト結果: 失敗 テスト期間: 0:00 :00.5728502
結果メッセージ: テスト メソッド Hc360LibTests.UnitTest1.TestMeetingCreation が例外をスローしました: System.ArgumentException: 空の文字列 '' は有効なローカル名ではありません。結果 StackTrace: Microsoft.Exchange.WebServices.Data.EwsServiceXmlWriter.WriteStartElement(XmlNamespace xmlNamespace, String localName) で System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName, String ns) で Microsoft.Exchange.WebServices.Data.PropertyBag Microsoft.Exchange.WebServices.Data.CreateRequest の .WriteToXml(EwsServiceXmlWriter ライター)
2.WriteElementsToXml(EwsServiceXmlWriter writer) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.WriteBodyToXml(EwsServiceXmlWriter writer) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.WriteToXml(EwsServiceXmlWriter writer) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.EmitRequest(IEwsHttpWebRequest request) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.BuildEwsHttpWebRequest() at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest
Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable1 items, FolderId parentFolderId, Nullable
1 messageDisposition, Nullableの 1.Execute()1 sendInvitationsMode, ServiceErrorHandling errorHandling)
c:\Users\okane\Documents\Visual Studio 2012\Projects の HealthCheck360ExchangeLib.CallSlotRepository.CreateTestAppointment() で Microsoft.Exchange.WebServices.Data.Appointment.Save(FolderId destinationFolderId, SendInvitationsMode sendInvitationsMode) で 1 messageDisposition, Nullable`1 sendInvitationsMode) \HealthCheck360OutlookCallScheduleHelper\HealthCheck360ExchangeLib\CallSlotRepository.cs:c:\Users\okane\Documents\Visual Studio 2012\Projects\HealthCheck360OutlookCallScheduleHelper\Hc360LibTests\UnitTest1.cs:Hc360LibTests.UnitTest1.TestMeetingCreation() の 70 行目:17 行目
at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable