c# - ASPNET 5 项目无法找到在引用的 DLL 中使用的端点配置 (ServiceModel)

标签 c# asp.net .net wcf dll

我正在开发一个新的 ASPNET 5 Web API 项目。我在该项目中引用的 .NET 3.5 dll 中调用类。在 dll 中,有一个提供某些所需功能的服务引用。

目前,在尝试调用dll中的类时,会出现类似如下的异常:

An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll but was not handled in user code

Additional information: Could not find endpoint element with name '****' and contract '****' 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 name could be found in the client element.

我已经尝试将与引用的 dll 同名的 .config 文件复制到/lib/dnx451 文件夹,但这并没有解决问题。我还尝试将 .config 文件复制到 artifacts 文件夹中的相应构建目录。

我也尝试过将 app.config 文件添加到 ASPNET 5 Web API 项目,但这会导致 dnx 无法构建项目。

由于工作的限制,我们无法对引用的 dll 进行任何更改。

我也想尝试添加具有完全相同的名称和契约(Contract)的服务引用,但是 ASPNET 5 项目没有为您提供添加服务引用的选项(只有一个连接的引用,这完全是另一回事)。

有没有人有这方面的经验?还是我遗漏了什么?

最佳答案

修复是将 Visual Studio 和 .NET Core 工具更新到最新版本。然后我在路由目录中创建了一个 app.config 并将配置从 dll 迁移到新的 app.config 中。

关于c# - ASPNET 5 项目无法找到在引用的 DLL 中使用的端点配置 (ServiceModel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39293915/

相关文章:

c# - 需要专家对 .net 应用程序最快通信的评论

c# - 什么是NullReferenceException,如何解决?

c# - 从 Web API 同步调用外部 API

c# - 不使用 Task.Result 的异步/等待死锁

asp.net - 创建 Entity Framework 数据库时出现 Mysql 语法错误

asp.net - 在 IIS 7.5 中为每个应用程序池设置 CLRConfig 文件

c# - "Dispose"是否处理设置为同一对象的类的每个实例?

c# - 获取 GameObject 引用的最快方法是什么?

c# - 从代码后面的输入框获取值

c# - 从 XDocument 获取 XmlElement