"Cannot complete this action" in SPRequestInternalClass.RenderListProperty for document library templates
February 20th, 2006 // 5:43 pm @ Amar
If you come across an error saying “Cannot complete this action” when trying to modify the document library template pages, with an exception trace showing a crash in SPRequestInternalClass.RenderListProperty, you have hit an issue similar to KB 901259.
I had a webpart which built a navigation tree by querying the subsites and document library subfolders under any site. As soon as I put them on the allitems.aspx page under the c:Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATE1033STSLISTSDOCLIB folder, I started receiving this error. Strangely when I placed the control at the end of the existing page it worked.
My code was as follows :
SPWeb currentWeb = SPControl.GetContextWeb(Context);
string currentSiteUrl = currentWeb.Url;
SPListCollection splstcol;
currentWeb.Lists.IncludeRootFolder = true;
splstcol = currentWeb.Lists;
If I placed my control before any calls to the or any such control which queried list properties, I was getting the above error.
The reason from what I figured out, is that SharePoint gives the reference to the current object when obtained from the GetContextWeb method. When I tried to set the IncludeRootFolder = true, I ended up modifying the properties of the current web object, and this somehow caused an internal crash whenever sharepoint tried to query list properties via calls to controls such as on the page. So when I placed my control at the end of the page, after all such controls it worked, but when any such ListProperty was queried after my control ran, it crashed.
The solution to overcome this problem was very simple. Do not get the existing object references, but create your own instance of the objects. So after modifying the code as follows, everything started working as it should be.
SPSite mySite = new SPSite(SPControl.GetContextWeb(Context).Url);
SPWeb currentWeb = mySite.OpenWeb();
string currentSiteUrl = currentWeb.Url;
SPListCollection splstcol;
currentWeb.Lists.IncludeRootFolder = true;
splstcol = currentWeb.Lists;
I haven’t checked to see if this happens on other such template pages, but in case it does, I guess the solution should be quite straightforward.
Category : SharePoint
Dan Winter [MSFT]
5 years ago
Well done, and a good read…
Demo
5 years ago
Very informative post… Thanks
http://
5 years ago
Stay alert for some memory leak in production environment if you don’t call Dispose at SPWeb instance.
http://
5 years ago
This is more then well done, for 3 weeks I was trying to solve the same problem and could not find an answer.
Thanks a million.
Now before call dispose, please read this http://support.microsoft.com/default.aspx?scid=kb;EN-US;901259
Ralph Krausse
4 years ago
I got this error because I was using impersonation within my code WindowsIdentity(). After looking at my code, I actually didn’t need this and it resolved that error message. I got the error message when I called the URL property of SPWeb AFTER I did the impersonation. Calling it before worked fine…
http://
3 years ago
very good