C# SqlDateTime溢出。在Windows应用商店应用程序中,必须介于1/1/1753 12:00:00 AM和12/31/9999 11:59:59 PM之间
我正在使用VS2013使用C#开发我的Windows应用商店应用程序 在这里,我调用一个服务调用来将图像上传为字节数组。请参见以下代码:C# SqlDateTime溢出。在Windows应用商店应用程序中,必须介于1/1/1753 12:00:00 AM和12/31/9999 11:59:59 PM之间,c#,wcf,windows-store-apps,winrt-xaml,winrt-async,C#,Wcf,Windows Store Apps,Winrt Xaml,Winrt Async,我正在使用VS2013使用C#开发我的Windows应用商店应用程序 在这里,我调用一个服务调用来将图像上传为字节数组。请参见以下代码: public async void SanUploadImage(byte[] data) { FileUploadDetailsRequest objFileUploadDetailsRequest = new FileUploadDetailsRequest();
public async void SanUploadImage(byte[] data)
{
FileUploadDetailsRequest objFileUploadDetailsRequest = new FileUploadDetailsRequest();
DocumentUploadServiceClient objDocumentUploadServiceClient = new DocumentUploadServiceClient();
string loginID = "259021";
objFileUploadDetailsRequest.AppId = 116; // ID card app id
objFileUploadDetailsRequest.AppTemplateId = "ERREY34654";
objFileUploadDetailsRequest.FileName = "MyFile.jpg";
objFileUploadDetailsRequest.IncomingFile = data;
objFileUploadDetailsRequest.CreatedBy = loginID;
objFileUploadDetailsRequest.CreatedDate = DateTime.Now;
objFileUploadDetailsRequest.AssociateId = 394346;
// Service method call
var objMFileuploadResponse = await objDocumentUploadServiceClient.UploadFile_WithResponseAsync(objFileUploadDetailsRequest);
}
在执行服务调用时,我遇到以下错误:
An exception of type 'System.ServiceModel.FaultException`1' occurred in mscorlib.dll but was not handled in user code
Additional information: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass5`1.<CreateGenericTask>b__4(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at SANTesting.MainPage.<SanUploadImage>d__7.MoveNext()
在mscorlib.dll中发生“System.ServiceModel.FaultException”“1”类型的异常,但未在用户代码中处理
其他信息:SqlDateTime溢出。必须在1753年1月1日12:00:00 AM和9999年12月31日11:59:59 PM之间。
在System.ServiceModel.Channels.ServiceChannel.ThrowiffaultUnderstanding处(消息回复、消息故障、字符串操作、消息版本、故障转换器故障转换器)
位于System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime操作,ProxyRpc&rpc)
位于System.ServiceModel.Channels.ServiceChannel.EndCall(字符串操作,对象[]输出,IAsyncResult结果)
在System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.c__DisplayClass5`1.b__4(IAsyncResult asyncResult)
在System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar、Func`2 endFunction、Action`1 endAction、Task`1 Promission、Boolean requiresSynchronization)
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中
在SANTesting.MainPage.d_u7.MoveNext()上
上述上载方法在从普通windows/asp.net应用程序执行时工作正常
请帮助您是否在清单功能中设置了客户端和服务器?是的。已经检查了这些功能。我可以在同一服务上调用其他方法服务器端的
FileUploadDetailsRequest
的定义是什么?字段名是否不匹配,或者是否有未在您端设置的DateTime
字段?该错误很可能只是意味着代码试图将未分配的DateTime
传递给数据库(这意味着它的默认值为0001-01-01,SQL Server不支持)。相同的调用代码在正常的C#windows应用程序中工作正常