Fixing error: SetConfigurationSettingPublisher needs to be called before FromConfiguration Setting can be used

I would like to thank Neil Mackenzie for this article. His input on the exception below [as commented in my previous post] lead to the content of this post.


In my previous post, I suggested a solution of above exception, and I received a comment from one of my readers that there is an easier way to solve the above exception as well. So I decided to make an article on the other solution as well.
At first I won't explain the solution in the previous article; it is harder than the solution provided here or vice versa.

Usually we read a connection string as:


DataConnectionString is name of the connection string in setting of WebRole.

To avoid the above exception read the connection string as:


So essentially,

  1. First get the configuration setting value
  2. Parse that

I hope this post would be useful to you in getting rid of above exception.

Recommended Free Ebook
Similar Articles