Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Web Service Config Error

Web Service Config Error

Scheduled Pinned Locked Moved C#
csharpjavacomtestingbeta-testing
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Programm3r
    wrote on last edited by
    #1

    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: ^_^

    P 1 Reply Last reply
    0
    • P Programm3r

      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: ^_^

      P Offline
      P Offline
      Programm3r
      wrote on last edited by
      #2

      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: ^_^

      D 1 Reply Last reply
      0
      • P Programm3r

        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: ^_^

        D Offline
        D Offline
        dojohansen
        wrote on last edited by
        #3

        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!

        L 1 Reply Last reply
        0
        • D dojohansen

          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!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          D 1 Reply Last reply
          0
          • L Lost User

            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.

            D Offline
            D Offline
            dojohansen
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups