I came across this Exception when trying to instantiate a connection to a third party web service. At the point of creating the client it would throw this exception.
The web reference had been added into a project rather than the web application, and the cause was invalid values in the Properties->Settings.settings file:
- The scope being set to User instead of Application
- The Type had defaulted to string instead of Web Service URL
Changing all the settings removed the exception.