Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误消息";Id的格式无效";设置开始日期时间对象时_C#_Exchangewebservices - Fatal编程技术网

C# 错误消息";Id的格式无效";设置开始日期时间对象时

C# 错误消息";Id的格式无效";设置开始日期时间对象时,c#,exchangewebservices,C#,Exchangewebservices,我可以利用您的帮助来理解最后一行中的错误消息试图告诉我什么 第二行是ok,完全可能在我保存约会之前还没有设置Id。 但为什么我可以改变主题和位置,但不能开始 app = new Appointment(ews); // unid = app.Id.UniqueId; <- throws error "The Id has an invalid format" app.Subject = ce.subject; app.Location = ce.location; app.Start =

我可以利用您的帮助来理解最后一行中的错误消息试图告诉我什么

第二行是ok,完全可能在我保存约会之前还没有设置Id。 但为什么我可以改变主题和位置,但不能开始

app = new Appointment(ews);
// unid = app.Id.UniqueId; <- throws error "The Id has an invalid format"
app.Subject = ce.subject;
app.Location = ce.location;
app.Start = DateTime.ParseExact(ce.startDate + " " + ce.startTime, datestring + 
            " " + timestring, null); // <- throws "The Id has an invalid format"
app=新预约(ews);

//unid=app.Id.UniqueId 这是用于提取日期的方法的签名

public static DateTime ParseExact(
    string s,
    string format,
    IFormatProvider provider
)
如果

  • s或format是空字符串
  • s不包含与格式中指定的模式对应的日期和时间
  • 小时组成和s中的AM/PM指示器不一致
    所以基本上如果你评论app.Start=。。。它正在工作?我没有尝试注释它,因为成功保存条目需要开始和结束。这如何回答问题?引发异常的不是那行代码?我猜“Id的格式无效”是一个格式异常……是的。我检查了,从客户端返回的JSON与我发送到那里的JSON不同。这比我做的还要容易。现在我将字符串改为DateTime,然后使用
    app.Start=ce.startDate.Date+ce.startTime.TimeOfDay,结束时相同,向前跳到下一个障碍物。。。剩下的唯一一个问题是“为什么错误消息会告诉我有关Id的信息?”我认为“Id的格式无效”是FormatException的默认消息(不确定,这里只是根据内存)