Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a WCF service reference in a .NET Core 3.1 application?

I'm attempting to add a WCF service reference to a .Net Core 3.1 web API. I'm using Visual Studio 2019 in admin mode. I get the following error:

Importing web service metadata ...
Number of service endpoints found: 1
Scaffolding service reference code ...
Error:Unable to generate deps.json, it may have been already generated.  You can specify the "-d" option before the tool name for diagnostic output (for example, "dotnet -d <toolname>": C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\GenerateDeps\GenerateDeps.proj

Anyone have any ideas how to resolve this?

I've tried installing dotnet-svcutil but I get the following error:

Package dotnet-svcutil 2.0.1 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package dotnet-svcutil 2.0.1 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any

like image 924
Bhav Avatar asked Apr 17 '20 15:04

Bhav


People also ask

Can we call WCF service from .NET Core?

To use WCF services in . NET Core, you need to create a proxy client of the required service. Proxy is actually a contract equivalent of actual service and contains complete details of the Interface and method exposed by WCF service. One can also use the Channel factory technique to connect to the WCF service easily.

How do you call a WCF service reference in C#?

With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.


1 Answers

Dotnet released preview of version 2.0.3. which work with dotnet Core 3.1. Install it trough package manager console and reopen project.

dotnet tool install --global dotnet-svcutil --version 2.0.3-preview1.20574.1

In solution explorer right click on project name -> Add -> Connected Service, should offer Microsoft WCF Web Service Reference Provider

like image 119
ElectroNis Avatar answered Oct 03 '22 02:10

ElectroNis