在 SharePoint 2010 中阅读文档时获取 ComException [英] getting ComException while reading the document in SharePoint 2010

查看:40
本文介绍了在 SharePoint 2010 中阅读文档时获取 ComException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站集中部署了 webpart.

这个 webpart 试图读取文档库中的文档内容.它在 SharePoint 2007 中工作正常.但这在 SharePoint 2010 中不起作用.如果文档大小较小,则其工作正常.否则我会收到以下异常.

<代码>Microsoft.SharePoint.SPException:无法打开文件文档库/MyDoc-FAQ.doc".---> System.Runtime.InteropServices.COMException (0x81070211): 无法打开文件文档库/MyOffice-FAQ.doc".在 Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) 在 Microsoft.SharePoint(USP)., String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) ---内部异常堆栈跟踪结束---在Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) 在 Microsoft.SharePoint.SPFile.String& etagNew、String& contentTagNew) 在 Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String&etagNew、String&contentTagNew) at Microsoft.SharePoint.SPFile.OpenBinaryStream() at MyComp.Plugin.Office.MyOffice.handleEdit(HtmlTextWriter writer, NameValueCollection querystring)Message isCannot open file "Document library/MyDoc-FAQ.doc".来源是 Microsoft.SharePoint 

示例代码

<预><代码>使用 (SPSite siteCol = new SPSite(siteurl)){使用 (SPWeb oWebsite = siteCol.OpenWeb()){oWebsite.AllowUnsafeUpdates = true;SPFolder 文件夹 = oWebsite.GetFolder(folderurl);SPFileCollection files = folder.Files;SPFile 文件 = 文件 [文件名];流流 = file.OpenBinaryStream();字节[]内容=空;BinaryReader reader = new BinaryReader(stream);content = reader.ReadBytes((int)file.Length);//如果文件大小较大,我得到异常oWebsite.AllowUnsafeUpdates = false;}}

文件大小超过 100kb 时发生错误.请帮我解决这个问题

在 SharePoint 日志中,我收到以下异常

<预><代码>在 Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundSqlFileFiller.StartNextFill(SPInterval iNext) 在 Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundFileFiller.DoNextOperation() 在 Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundFileFiller.Fill() 在 Microsoft.SharePoint.CoordinatedStreamBufferFactory.SPCoordinatedStreamBufferFactory.SPCoordinatedStreamBufferFactory.DoNextOperation()会话、Guid guidSiteId、Int32 grfDocFlags、Int64 cbContent、SPChunkedArray`1 rgbContent、Byte[] rgbRbsId、Guid guidDoc、Int32 iInternalVersion、Int32 pageSize、Boolean bStartFilling)在 Microsoft.SharePoint.CoordinatedStreamDataBufferFactory(CoordinatedStreamDataBuffer).行、SPDocumentBindRequest& dbreq、SPDocumentBindResults& dbres) 在 Micr... 1cc7f9da-32ed-4446-aaa7-8bc6dd4cd63510/14/2010 19:27:18.77* w3wp.exe (0x1F28) 0x1ED0 SharePoint Foundation 数据库 fa46 高 ...osoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(字符串 bstrUrl、字符串 bstrWebRelativeUrl、gr obaryfBytesLevel、布尔值 bHonor, 字符串 bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String&pEString& pESPFile.GetFileStreamCore(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew) at Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew) at Microsoft.SharePoint.SPFile.OpenBinary...(SPOpenBinary)1cc7f9da-32ed-4446-aaa7-8bc6dd4cd63510/14/2010 19:27:18.77* w3wp.exe (0x1F28) 0x1ED0 SharePoint Foundation 数据库 fa46

解决方案

我遇到了同样的问题……原来是鬼.我可以在文档库中看到该文件(在本例中为 xslt),我可以在管理所有内容中看到它,但是当我使用 URL 导航到该文件时,IIS 不会提供该文件.我是服务器的管理员,所以应该不是权限问题.

我只是通过重新上传文件(相同的名称和属性)解决了这个问题 - 突然我的 System.Runtime.InteropServices.COMException (0x81070211):无法打开文件错误消失了.

放弃吧,如果它对你有用,请告诉我.

丰富

I deployed webpart in the site collection.

This webpart tried to read the content of the document in the document library. Its work fine in SharePoint 2007. But this is not working in SharePoint 2010. If the document size is small, its working fine. otherwise i am getting the following Exception.


Microsoft.SharePoint.SPException: Cannot open file "Document library/MyDoc-FAQ.doc". ---> System.Runtime.InteropServices.COMException (0x81070211): Cannot open file "Document library/MyOffice-FAQ.doc". at Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) --- End of inner exception stack trace --- at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew) at Microsoft.SharePoint.SPFile.GetFileStreamCore(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew) at Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew) at Microsoft.SharePoint.SPFile.OpenBinaryStream() at MyComp.Plugin.Office.MyOffice.handleEdit(HtmlTextWriter writer, NameValueCollection querystring)Message isCannot open file "Document library/MyDoc-FAQ.doc". source is Microsoft.SharePoint 

Sample Code



  using (SPSite siteCol = new SPSite(siteurl))
            {
                using (SPWeb oWebsite = siteCol.OpenWeb())
                {
                    oWebsite.AllowUnsafeUpdates = true;

                    SPFolder folder = oWebsite.GetFolder(folderurl);
                    SPFileCollection files = folder.Files;

                    SPFile file = files[filename];
                     Stream stream = file.OpenBinaryStream();
                     byte[] content = null;
                     BinaryReader reader = new BinaryReader(stream);

                     content = reader.ReadBytes((int)file.Length);//If the document size is higher, i am getting exception

                     oWebsite.AllowUnsafeUpdates = false;

                  }


            }    

Error occurs when the file size is exceed 100kb. Please help me to overcome this issue

In the SharePoint log i got the following exception


   at Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundSqlFileFiller.StartNextFill(SPInterval iNext)     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundFileFiller.DoNextOperation()     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPBackgroundFileFiller.Fill()     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocParams(SqlSession session, Guid guidSiteId, Int32 grfDocFlags, Int64 cbContent, SPChunkedArray`1 rgbContent, Byte[] rgbRbsId, Guid guidDoc, Int32 iInternalVersion, Int32 pageSize, Boolean bStartFilling)     at Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocumentRowset(SqlSession session, Object[] row, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres)     at Micr... 1cc7f9da-32ed-4446-aaa7-8bc6dd4cd635
10/14/2010 19:27:18.77* w3wp.exe (0x1F28)                           0x1ED0  SharePoint Foundation           Database                        fa46    High        ...osoft.SharePoint.Library.SPRequestInternalClass.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew)     at Microsoft.SharePoint.Library.SPRequest.GetFileAsStream(String bstrUrl, String bstrWebRelativeUrl, Boolean bHonorLevel, Byte iLevel, OpenBinaryFlags grfob, String bstrEtagNotMatch, String& pEtagNew, String& pContentTagNew)     at Microsoft.SharePoint.SPFile.GetFileStreamCore(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew)     at Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew)     at Microsoft.SharePoint.SPFile.OpenBinary(SPOpenBinary...  1cc7f9da-32ed-4446-aaa7-8bc6dd4cd635
10/14/2010 19:27:18.77* w3wp.exe (0x1F28)                           0x1ED0  SharePoint Foundation           Database                        fa46

解决方案

I had this same issue... turned out it was a ghost. I could see the file in the document library (xslt's in this case) and I could see it in Manage All Content, but IIS would not serve the file when i navigated to it using the URL. I am admin on the server so it should not be a permissions issue.

I solved the issue simply by re-uploading the file (same name and properties) - suddenly my System.Runtime.InteropServices.COMException (0x81070211): Cannot open file error went away.

Give it go and let me know if it worked for you.

Rich

这篇关于在 SharePoint 2010 中阅读文档时获取 ComException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆