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 Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\1033\STS\LISTS\DOCLIB 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.