May 16, 2019

Root Element Missing when connecting to SharePoint online via CSOM/Powershell on windows 10 machine

Hello friends,

Recently i got a situation where suddenly my csom code is stopped working . This CSOM code is to connect a SharePoint online site to fetch data from some list. The same code was running fine earlier.

Issue Description:

When connecting to SharePoint Online site using CSOM or Powershell(using Connect-SPOService command) from Windows 10 machine getting an error "Root Element Missing"

CSOM error : 

At context.ExecuteQuery it thrown "Root Element Missing" with below stack trace




Powershell Error :



Tried in different ways to fix this, like from changing the schema of my app config file, clearing VS cache , running on new version vs 2019 professional , by referring the new CSOM dlls ,clearing Nuget Package cache and finally formatting windows 10. But none of them helped me out.

also

1> The same code worked in other machine
2> The same code working for other online sites from same machine

I was so confused that, whether it is an issue from my machine or the SharePoint site. I noticed that, the stack trace is clearly showing there is an xml notation issue in SharePoint Client libraries.

Finally after troubleshooting for days i found that the issue is with my ISP( Internet Service Provider ) /internet settings.

Resolution :
Changing the DNS settings will resolve this issue. Here are the steps.

Go to Control Panel --> Network and Internet --> Change Adapter Settings --> Select the Network through which you are connecting to Internet



Right click on it and Select Properties. Then select Internet Protocol Version 4 (TCP/IPV4) and select properties



Then select the "Use the following DNS Server Addresses" instead obtain DNS server addresses automatically and give the DNS whatever you want. Here i gave the free DNS address which is offered by google.

Google public DNS addresses : 8.8.8.8 and 8.8.8.4 

Then say OK to apply these changes.

I ran the code again , both csom and powershell worked well without any issues.

References :
https://www.koskila.net/fixing-security-reasons-dtd-prohibited-xml-document-issue/
http://asp.net-hacker.rocks/2016/01/15/XML-parsing-problem-because-of-your-ISP.html
https://www.windowscentral.com/how-change-your-pcs-dns-settings-windows-10

Hope this helps somebody.

Thanks
Purna