【问题标题】:How to include Web reference endpoint configuration in another project如何在另一个项目中包含 Web 参考端点配置
【发布时间】:2011-05-30 17:19:38
【问题描述】:

我有 2 个项目,X 和 Y。Y 调用 Web 服务,配置在 Y 的 app.config(它的 DLL)中定义。

当 X 调用 Y 方法时,我得到以下异常:

 System.InvalidOperationException: Could not find default endpoint element that references contract 'xxxx.ServiceSoap' 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.

如何将 Y 的 app.config 包含/导入到 X 的 web.config 中,以便它具有此配置?

谢谢!

【问题讨论】:

    标签: c# app-config


    【解决方案1】:

    您不能将一个项目的配置文件包含到另一个项目中。

    您可以做的是在 X 项目中创建一个新的配置文件(仅包含该 Web 服务的配置),然后将该配置文件包含到 X 的主 web.config 中。

    例如。

    假设您创建了一个名为“Endponts.config”的新配置文件

    看起来像

    <endpoints>
    ......
    </endpoints>
    

    然后您可以通过以下方式在主 web.config 文件中使用此 Endpoints.config 文件

    <system.web>
        ...
        <endpoints configSource="Endponts.config" />
        ...
      </system.web>
    

    【讨论】:

    • 您确定它应该驻留在 中吗?
    • 这取决于您要导入哪些设置,标准 Web 设置进入 ,现在您的情况是端点(您充当客户端),然后它将进入 。 serviceModel>/.
    猜你喜欢
    • 2010-12-02
    • 1970-01-01
    • 2011-10-25
    • 2011-01-19
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多