Antonio Fernández
Antonio Fernández

Reputation: 103

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.

Upvotes: 0

Views: 3808

Answers (2)

ta.speot.is
ta.speot.is

Reputation: 27214

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

Upvotes: 4

Henk Holterman
Henk Holterman

Reputation: 273169

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.

Upvotes: 2

Related Questions