我正在写一个小的网络接口,它在系统中心的安装程序的前面。它应该击中运行簿,并得到一些数据-这部分很大程度上是不重要的。
该代码试图从https://msdn.microsoft.com/en-us/library/hh921685.aspx启动一个runbook作业,以便使用示例代码(并在我的需求中细分)获取一些数据。
我更改的唯一行是对我自己的Orchestrator、runbook GUID和runbook参数的引用。
这一行在标题中抛出异常:
context.SaveChanges();
其中的堆栈跟踪显示错误似乎起源于OData领域的某个地方,这远远超出了我的代码范围:
[ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000.
Parameter name: offset]
System.DateTimeOffset.ValidateDate(DateTime dateTime, TimeSpan offset) +14215620
System.DateTimeOffset..ctor(DateTime dateTime) +56
Microsoft.Data.OData.Atom.EpmSyndicationWriter.CreateDateTimeStringValue(Object propertyValue, ODataWriterBehavior writerBehavior) +144
Microsoft.Data.OData.Atom.EpmSyndicationWriter.WriteEntryEpm(EntryPropertiesValueCache epmValueCache, IEdmEntityTypeReference entityType) +652
Microsoft.Data.OData.Atom.EpmSyndicationWriter.WriteEntryEpm(EpmTargetTree epmTargetTree, EntryPropertiesValueCache epmValueCache, IEdmEntityTypeReference type, ODataAtomOutputContext atomOutputContext) +80
Microsoft.Data.OData.Atom.ODataAtomWriter.EndEntry(ODataEntry entry) +627
Microsoft.Data.OData.ODataWriterCore.<WriteEndImplementation>b__16() +168
Microsoft.Data.OData.ODataWriterCore.InterceptException(Action action) +121
Microsoft.Data.OData.ODataWriterCore.WriteEndImplementation() +69
Microsoft.Data.OData.ODataWriterCore.WriteEnd() +40
System.Data.Services.Client.ODataWriterWrapper.WriteEnd(ODataEntry entry, Object entity) +47
System.Data.Services.Client.Serializer.WriteEntry(EntityDescriptor entityDescriptor, IEnumerable`1 relatedLinks, ODataRequestMessageWrapper requestMessage) +485
System.Data.Services.Client.BaseSaveResult.CreateRequestData(EntityDescriptor entityDescriptor, ODataRequestMessageWrapper requestMessage) +117
System.Data.Services.Client.BaseSaveResult.CreateChangeData(Int32 index, ODataRequestMessageWrapper requestMessage) +136
System.Data.Services.Client.SaveResult.CreateNonBatchChangeData(Int32 index, ODataRequestMessageWrapper requestMessage) +224
System.Data.Services.Client.SaveResult.CreateNextChange() +174
System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options) +178
System.Data.Services.Client.DataServiceContext.SaveChanges() +37
S3Tools.RunbookOperations.GetClusters(String site) in [redacted]\RunbookOps.cs:58
我看过The UTC time represented when the offset is applied must be between year 0 and 10,000. Parameter name: offset和UTC time represented when the offset is applied must be between year 0 and 10,000 error,它看起来很像那个调用https://support.microsoft.com/en-us/kb/2346777的错误(特别是后者),但是MS提供的修补程序不适用于Windows10(我的工作站)或Windows2012 R2 ( but服务器)。
我不愿意改变我的时区(UTC+10)或服务器的测试之前,看看是否有人有任何想法或遇到过这种情况。
我有powershell脚本,它们非常能够生成这些作业(尽管它们不能使用服务引用,但您必须手动生成请求)。所以我倾向于相信除了CLR之外,任何事情都是错误的。
底线问题:有没有人遇到过这个问题并修复了它?
发布于 2016-04-19 22:17:07
增加这两行将缓解这一问题:
job.CreationTime = DateTime.Now;
job.LastModifiedTime = DateTime.Now;
或者,当然,对于任何合理有效的DateTime值。
因此,当使用问题中提到的示例代码时,空的Job对象没有填充CreationTime或LastModifiedTime属性,因此它会传递给它。当时间被用于计算时,就会产生一个<0或>10,000年的时差。
解决方案出现在technet论坛线程中:https://social.technet.microsoft.com/Forums/en-US/e248ecef-9561-4409-8a3f-8299bcc721a4/exception-using-code-sample-in-utc-1-timezone?forum=scoqik
JoakimJohansson给出的答案。
https://stackoverflow.com/questions/36708822
复制相似问题