0

I added a .NET 2.0 web reference with the Visual Studio IDE, but for this specific case it can't be configured using the app.config file.

So I tried to initialize it this way:

var service = new MyWebservice
{
   Url = config.MyWebserviceUrl
};

But I get the following exception:

Value cannot be null. Parameter name: uriString

config.MyWebserviceUrl contains a valid web address.

What is the correct way to configure and initialize a webservice programatically?

xsl
  • 17,116
  • 18
  • 71
  • 112

1 Answers1

2

Have you checked the URL Behavior setting for the web reference? If it's Dynamic, it will be attempting to get the URL from the config file.

This question covers programmatic configuration of the URL in more detail:

How can I dynamically switch web service addresses in .NET without a recompile?

Community
  • 1
  • 1
Dave R.
  • 7,206
  • 3
  • 30
  • 52