While reading the web.config file from non web application you might receive the error “NullReferenceException was unhandled” like below.
When you drill down using the Locals window then you will see the FilePath property is pointing to C:\\Windows…..
This is because of the null in the following line.
System.Configuration.Configuration cf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
Replace the null with the web application like the one in How to read connection string from web.config in non-web application.