2

我有一个将 .pdf 保存到 SharePoint 文档库的 Windows 应用程序。除了这个文件外,它工作正常。每当我对这个 10.1MB 的文件使用 SaveBinaryDirect 时,都会出现以下异常:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
   at Microsoft.SharePoint.Client.File.SaveBinary(ClientContext context, String serverRelativeUrl, Stream stream, String etag, Boolean overwriteIfExists, SaveBinaryCheckMode checkMode)
   at Microsoft.SharePoint.Client.File.SaveBinaryDirect(ClientContext context, String serverRelativeUrl, Stream stream, Boolean overwriteIfExists)
   at BKWatch.BKWatchViewModel.UploadDocument(String siteURL, String documentListName, String documentListURL, String documentName, Byte[] documentStream, Int64 AccountId, String DebtorName, Nullable`1 Pages, String Title) 

我已经尝试过以下方法:

clientContext.PendingRequest.RequestExecutor.WebRequest.KeepAlive = false;

System.Net.ServicePointManager.MaxServicePointIdleTime = 600000;
 clientContext.RequestTimeout = 600000;

在 SharePoint 中增加最大大小 - 已经达到 50 MB 在 IIS web.config 中增加最大大小 - 已经达到 2GB

谢谢。

4

2 回答 2

0

好吧,在与 Microsoft 进行了几次长时间的电话交谈后,他们认为 SaveBinaryDirect 代码中存在错误,并建议我改用 ClientObject.Add 功能。到目前为止似乎正在工作。

于 2013-07-12T22:37:27.303 回答
0

连续上传多个大文件时,我遇到了 Microsoft.SharePoint.Client.File.SaveBinaryDirect 这个问题。

每次使用 SaveBinaryDirect 时都可以解决此问题,使用 try-catch 对其进行包装,然后捕获 System.Net.WebException。

一旦 Webexception 被捕获,运行之前运行的相同 SaveBinaryDirect 命令,它应该可以工作。

于 2015-10-21T07:11:18.893 回答