Search code examples
c#wpfwcf.net-core-3.0

How use wcf from wpf developed in .net core 3.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.


Solution

  • 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