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

时间:2022-10-24 05:33:21

I'm developing a new ASPNET 5 Web API project. I'm calling classes within a .NET 3.5 dll referenced in that project. Within the dll, there is a service reference providing certain required functionality.

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

Currently, when trying to call the classes in the dll, we get an exception similar to the following:

目前,在尝试调用dll中的类时,我们得到类似于以下内容的异常:

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

System.ServiceModel.dll中出现“System.InvalidOperationException”类型的异常,但未在用户代码中处理

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.

附加信息:无法在ServiceModel客户端配置部分中找到名称为“****”且合同为“****”的端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

I've tried copying the .config file with the same name as the referenced dll to the /lib/dnx451 folder but this has not solved the problem. I've also tried copying the .config file to the appropriate build directory in the artifacts folder.

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

I've also tried adding an app.config file to the ASPNET 5 Web API project, but this causes dnx to fail to build the project.

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

Due to the limitations of the work, we're unable to make any changes in the referenced dll.

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

I also wanted to try adding the service reference with the exact same name and contract, but an ASPNET 5 project does not give you an option to add a service reference (only a connected reference which is a different thing altogether).

我还想尝试添加具有完全相同名称和合同的服务引用,但是ASPNET 5项目没有为您提供添加服务引用的选项(只有连接引用完全不同)。

Has anyone had any experience with this? Or is there something that I am missing?

有没有人有这方面的经验?或者有什么我想念的东西?

2 个解决方案

#1


0  

Fix was to update Visual Studio and the .NET Core tooling to the latest. Then I created an app.config in the route directory and migrated the config from the dll into the new app.config.

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

#2


0  

You can programmatically do this with out using config settings or you can add a rex file and in that file you can save your binding/contract details. The problem is config file is move with the dll so you can't get these details from a reference dll but rex file is move attached into the dll.

您可以使用配置设置以编程方式执行此操作,也可以添加rex文件,并在该文件中保存绑定/合同详细信息。问题是配置文件随着dll一起移动,所以你不能从引用dll获取这些细节,但是rex文件被移动到dll中。

#1


0  

Fix was to update Visual Studio and the .NET Core tooling to the latest. Then I created an app.config in the route directory and migrated the config from the dll into the new app.config.

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

#2


0  

You can programmatically do this with out using config settings or you can add a rex file and in that file you can save your binding/contract details. The problem is config file is move with the dll so you can't get these details from a reference dll but rex file is move attached into the dll.

您可以使用配置设置以编程方式执行此操作,也可以添加rex文件,并在该文件中保存绑定/合同详细信息。问题是配置文件随着dll一起移动,所以你不能从引用dll获取这些细节,但是rex文件被移动到dll中。