简体   繁体   English

如何在另一个项目中包含 Web 参考端点配置

[英]How to include Web reference endpoint configuration in another project

I have 2 projects, X and Y. Y calls a Web service and the configuration is defined in Y's app.config (its a DLL).我有 2 个项目,X 和 Y。Y 调用 Web 服务,配置在 Y 的 app.config(它的 DLL)中定义。

When X calls Y methods, I get the following exception:当 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.

How can I include/import Y's app.config into X's web.config so it will have this configuration?如何将 Y 的 app.config 包含/导入到 X 的 web.config 中,以便它具有此配置?

Thank you!谢谢!

You can not include configuration files of one project into another.您不能将一个项目的配置文件包含到另一个项目中。

What you can do is make a new configuration file in X project (that has only the configuration for that web service) and then include that configuration file into your main web.config of X.您可以做的是在 X 项目中创建一个新的配置文件(仅包含该 web 服务的配置),然后将该配置文件包含到 X 的主 web.config 中。

eg.例如。

Lets say you make a new configuration file with name "Endponts.config"假设您创建了一个名为“Endponts.config”的新配置文件

it looks like看起来像

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

and then you can use this Endpoints.config file in your main web.config file in the following manner然后您可以通过以下方式在主 web.config 文件中使用此 Endpoints.config 文件

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio项目:如何仅包括一种配置的参考? - Visual Studio Project: How to include a reference for one configuration only? 如何通过反射引用另一个项目中的EF配置? - How do I reference an EF Configuration in another project via reflection? 如何在另一个项目的接口中引用 ViewModels(在单独的 Web 项目中)? - How to reference ViewModels (in separate Web project) in an Interface in another project? 如何在另一个项目中引用Web API? - How do I reference a Web API in another project? 带有服务参考的项目参考:未知端点 - Reference to project with service reference: Unknown endpoint 如何在另一个项目中引用 Fody MethodDecorator? - How to reference a Fody MethodDecorator in another project? 如何引用另一个项目的.EDMX model? - How to reference the .EDMX model of another project? C# - 如何在当前项目中使用另一个项目日志配置? - C# - How to use another project logging configuration into current project? 如何从另一个项目访问位于一个项目中的配置文件 - How to access a configuration file located in one project from another project 如何在版本的.dll中包含项目所需的参考 - How to include required reference for project in it's release .dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM