Web Service Config Error
-
Hi all, I have created a two projects that calls a web service. The one project is a library and the other one is a console application (console application is for testing purposes). When I call the web service from the console application everything works like it should, but as soon as I make use of the library (from a different console application that calls the library) I receive the following error message:
Could not find default endpoint element that references contract 'ServiceReference.IMobileService' in the ServiceModel client configuration section.
This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.I have tried placing the .config file every where, but I keep receive the error. Can anyone please assist me in this matter? Many thanks in advance. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
Hi all, I have created a two projects that calls a web service. The one project is a library and the other one is a console application (console application is for testing purposes). When I call the web service from the console application everything works like it should, but as soon as I make use of the library (from a different console application that calls the library) I receive the following error message:
Could not find default endpoint element that references contract 'ServiceReference.IMobileService' in the ServiceModel client configuration section.
This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.I have tried placing the .config file every where, but I keep receive the error. Can anyone please assist me in this matter? Many thanks in advance. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
Solotion: A library cannot consume it's own cnfig file when called by another application, it must make use of the host / calling applications config file, thus place any config information into the .exe.config file in order for it to work. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
Solotion: A library cannot consume it's own cnfig file when called by another application, it must make use of the host / calling applications config file, thus place any config information into the .exe.config file in order for it to work. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
Indeed, but why are MS so lazy that they can't be bothered to report different error messages for rather different cases!? It's pretty obvious that the code that generated that error knows bloody well whether the problem is that the file was not found, or no endpoint definition was found in the file. But to save five minutes they used one message for both conditions, leaving tens of thousands of developers to waste their time because they don't know if it's the location of the file or the contents of it that is the problem! By the way, this is something most of us can be a lot better at: Whenever we write code we should try to keep in mind what users of the code (including ourselves - we won't remember all the implementation details well for long) might do and report errors as clearly and specifically as possible. Lakmus test: If your code doesn't have a lot more throw statements than catch blocks, it's almost certainly not very good!
-
Indeed, but why are MS so lazy that they can't be bothered to report different error messages for rather different cases!? It's pretty obvious that the code that generated that error knows bloody well whether the problem is that the file was not found, or no endpoint definition was found in the file. But to save five minutes they used one message for both conditions, leaving tens of thousands of developers to waste their time because they don't know if it's the location of the file or the contents of it that is the problem! By the way, this is something most of us can be a lot better at: Whenever we write code we should try to keep in mind what users of the code (including ourselves - we won't remember all the implementation details well for long) might do and report errors as clearly and specifically as possible. Lakmus test: If your code doesn't have a lot more throw statements than catch blocks, it's almost certainly not very good!
You need to learn more on how .NET configuration system works. It will never report a missing configuration file since there is always a master config file with default settings (machine.config). What you put in your application's config file just overrides (or adds to) those values. Configuration files are typically attached to processes. Since a .NET library is not loaded into its own process but loaded into the calling process, it uses the calling process's config file. It is a mistake that every newbie makes.
-
You need to learn more on how .NET configuration system works. It will never report a missing configuration file since there is always a master config file with default settings (machine.config). What you put in your application's config file just overrides (or adds to) those values. Configuration files are typically attached to processes. Since a .NET library is not loaded into its own process but loaded into the calling process, it uses the calling process's config file. It is a mistake that every newbie makes.
Well why should the message then read This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element. I do know about the cascading of config files - a great feature btw - but I do not know every detail about what can be configured in machine.config versus web.config/app.config, nor do I remember exactly how web services and WCF services are configured. In general however I have to say .NET usually does a fairly good job with error messages, compared to anything else I've used. That doesn't mean it's the right tradeoff tho! For every small improvement in the error reporting of any library used by many people, a lot of people can end up saving some time, and in aggregate quite a lot of time. That's the point I want to get across.