How set Webservice configuration by specifying a app.config file RRS feed

  • Question

  • Hi,

    I have a class library that references a WebService. The configuration settings for this WebService are on the DLL app.config.

    Then I have an EXE that uses this DLL to use the WS. When I invoke a method on the WS I get the following message:

    "Could not find default endpoint element that references contract 'XXXXXXXXX' 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 suppose I get this error because the app.config of the exe does not have the WS configuration.

    I've already concluded that if I move the contents of the DLL app.config to the exe app.config it works, but I don't want to do this.

    I want to use the contents of the DLL app.config to configure the WS on the fly (similar to what is possible to do with .NET Remoting with RemotingConfiguration class).

    Is this possible?

    Thanks in advance

    Thursday, November 11, 2010 1:59 PM


  • > I've already concluded that if I move the contents of the DLL app.config

    .NET does not support a separate config file for the DLL.  You must merge into the EXE.

    As an alternative, note that it is possible to configure practically everything in WCF at runtime instead of using the automatic configuration which is pulled from the web.config file.  Basically mostly everything you can get in the config file, you can write corresponding code on WCF object model.

    For example, the sample at uses no configuration file at all.



    • Marked as answer by SamAgain Friday, November 19, 2010 4:54 AM
    Friday, November 12, 2010 2:47 AM