0

I need to use a WCF service from WPF developed in .NET Core 3.0 preview 5. In Visual Studio I cannot use Add -> Service reference because VS doesn't support this option now.

My first option is write in .csproj all components I need to running my project, but It doesn't work.

This is my .csproj.

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <None Include="Connected Services\ServiceTime\Time.wsdl" />
    <None Include="Connected Services\ServiceTime\Time.xsd">
      <SubType>Designer</SubType>
    </None>
    <None Include="Connected Services\ServiceTime\Time1.xsd">
      <SubType>Designer</SubType>
    </None>
  </ItemGroup>
  <ItemGroup>
    <WCFMetadata Include="Connected Services\" />
  </ItemGroup>
  <ItemGroup>
    <WCFMetadataStorage Include="Connected Services\ServiceTime\" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Connected Services\ServiceTime\Time.disco" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Connected Services\ServiceTime\configuration91.svcinfo" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Connected Services\ServiceTime\configuration.svcinfo" />
  </ItemGroup>
  <ItemGroup>
    <None Include="Connected Services\ServiceTime\Reference.svcmap">
      <Generator>WCF Proxy Generator</Generator>
      <LastGenOutput>Reference.cs</LastGenOutput>
    </None>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Windows.Compatibility" Version="2.1.1" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="TimeService">
      <HintPath>..\..\TimeService\TimeService\bin\TimeService.dll</HintPath>
    </Reference>
  </ItemGroup>
</Project>

TimeService is working correctly.

If anyone knows a guide about use WCF service in WPF use .NET Core 3.0 let me know please.

  • Wcf isn't implemented in net core. I never tried but it doesn't surprise me you can't consume wcf. You're supposed to use a restful service such as web api now. – Andy May 22 '19 at 09:58
  • 1
    @Andy - client side _is_ implemented. – H H May 22 '19 at 10:20
  • And as for alternatives (server side), MS is hinting at gRPC – H H May 22 '19 at 11:09

2 Answers2

4

I need to use a WCF service from WPF developed in .NET Core 3.0 preview 5. In Visual Studio I cannot use Add -> Service reference because VS doesn't support this option now.

For .NET Core you add it as a Connected Service.

Use the WCF Web Service Reference Provider Tool

...

The WCF Web Service Reference option is applicable to projects created using the following project templates:

  • Visual C# > .NET Core
  • Visual C# > .NET Standard
  • Visual C# > Web > ASP.NET Core Web Application

...

  1. In Solution Explorer, double-click the Connected Services node of the project
  2. On the Connected Services page, click Microsoft WCF Web Service Reference Provider. This brings up the Configure WCF Web Service Reference wizard: enter image description here
Community
  • 1
  • 1
ta.speot.is
  • 26,914
  • 8
  • 68
  • 96
  • Does that work for *any* WCF service? Any binding, any contract? Or just SOAP services with a WSDL? – nvoigt May 22 '19 at 10:28
  • 1
    @nvoigt It supports at least SOAP, websockets and net.tcp https://github.com/dotnet/wcf/tree/master/src/System.Private.ServiceModel/src/System/ServiceModel Also duplex where the binding supports it. No msmq. `dotnet-svcutil` isn't as mature as `svcutil` but for the most part you can wrangle it to do what you need. – ta.speot.is May 22 '19 at 10:37
2

I cannot use Add -> Service reference because VS doesn't support this option now.

Yes it does. It's under "Add Connected Services".

It seems you want to add a WCF client, but do be clear about that. WCF services are not supported on Core.

H H
  • 263,252
  • 30
  • 330
  • 514