我正在开发一个新的 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/