"DTD is prohibited" error when accessing sharepoint 2013/office365 list (but not openly aware of using XML)

StackOverflow https://stackoverflow.com/questions/23443316

Вопрос

I've been getting a list of folders and files from Sharepoint (on Office 365) by using the following code...

...
   var folders = ListFolders(libraryName, clientContext, web);
...

public List<Folder> ListFolders(string libraryName, ClientContext clientContext, Web web)
    {
        var list = GetDocumentLibrary(libraryName, clientContext, web);
        var folders = list.RootFolder.Folders;
        clientContext.Load(folders);
        clientContext.ExecuteQuery();
        return folders.ToList();
    }

public List GetDocumentLibrary(string libraryName, ClientContext clientContext, Web web)     
        {
            var query = clientContext.LoadQuery(web.Lists.Where(p => p.Title == libraryName));
            clientContext.ExecuteQuery();
            return query.FirstOrDefault();
        }

It was working fine until I rebooted my computer (it installed a Windows Update), I strongly suspect, based on some testing I've done, it seems this is caused by http://support.microsoft.com/kb/2964358.

When the clientContext.ExecuteQuery() statement is reached in GetDocumentLibrary(), the following exception is thrown.

An unhandled exception of type 'System.Xml.XmlException' occurred in System.Xml.dll Additional information: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.

I'm wondering how I can work around this, as I'm not consciously using System.XML, it's a background function or process when the ExecuteQuery runs.

Can I pass some additional XMLReader info to this or clientContext (I'm assuming not), so I'm not sure how to execute this query to prevent the DTD error. I have also tried accessing the list in a different manner, by using this code... (from Microsoft's MSDN pages)

List list = clientContext.Web.Lists.GetByTitle(libraryName);
        CamlQuery camlQuery = new CamlQuery();
        camlQuery.ViewXml = "<View/>";
        ListItemCollection listItems = list.GetItems(camlQuery);
        clientContext.Load(list); clientContext.Load(listItems);
        clientContext.ExecuteQuery();

This works on a computer without the KB above, however on my PC it doesn't (I get the same exception as my other code) , obviously uninstalling the KB will make things work in the short term, but its no good in the longer term. Any advice on how to avoid this error would be greatly appreciated. I can only assume there will be a "preferred" way from Microsoft for accessing lists now this KB is implemented, but I'm clueless as to what it is. Thanks

Dougie

Это было полезно?

Решение

I was using a 2nd router as a WiFi extender, this seemed to have an odd, but reproducable effect when connecting to sharepoint, I stopped using it and used my main router/wifi box and my problem disappeared.

Другие советы

I had this same issue on a Virgin Media (UK based ISP) internet connection. It turns out that Virgin Media intercept web calls for the purpose of "advanced network error search". Luckily you can opt out from this. As soon as I did that it worked fine.

More details on the cause and how to opt out from Virgin Media's advanced search here: http://pryankrohilla.blogspot.co.uk/2014/05/error-resolved-connect-sposervice-for.html

I'm not happy about this, I left tweaking my program with a view to doing more diagnostics this morning, but now the issue seems to have mysteriously stopped happening, whether this has been tweaking at the MS end or not, or perhaps a glitch in SharePoint I've no idea, I don't think it's been my laptop since it's been on since I had the issue.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top