Is it possible to upgrade a Windows 8.1 App to a UWP Windows 10 app and have WCF project within the UWP app?

0

I need to upgrade an existing windows 8.1 Mobile app to work on windows 10 and started looking into this.

I have managed to port the code to UWP and it builds and runs the UWP app - so far so good.

However within the app there is a WCF project which is used to go get data and this isn't working.

I am currently getting this error Could not load file or assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Is it even possible for a UWP app to contain a WCF project and this will work? In the VS2015 solution this all works but in VS2019 it doesn't work as in the ServiceFactory class cant even create an instance.

I have next to no experience of UWP or Windows 8.1 Mobile apps and any advice would be great.

Thanks Gregor

wcf
uwp
windows-8.1-universal
asked on Stack Overflow Mar 4, 2020 by gsuttie

1 Answer

0

Note that the WCF Client is actually available for .NET Core/.NET Standard! It's only the server-side part that is not available for .NET Core.

  • WCF Service: .NET Framework
  • WCF Client: .NET Standard based (works with .NET Core and .NET Framework)

In your case, if I understand you correctly, you want to call an existing service, which means you need the WCF client, and you can actually use that WCF client with .NET Core/.NET Standard 2.0 and so also with UWP.

Do the following:

  1. Add a new .NET Standard Class Library project to your solution (this will replace the WCF client library that you have already in your solution)
  2. In Solution Explorer, right click on Dependencies and select "Add Connected Service"

enter image description here

  1. This will bring up a page within Visual Studio where you see the "Microsoft WCF Web Service Reference Provider":

Click on this to add a WCF Service reference

Click on it, and the dialog below opens up:

enter image description here

  1. In the dialog above, type in the URL of your service, and the dialog will generate the whole WCF client code for you and it will also add references for the required WCF NuGet packages.

  2. Reference the .NET Standard 2.0 class library project from your UWP project and use it.

Note: WCF-Client in .NET Core does not support the configuration file entries known from .NET Framework projects. That means that the configuration is generated in the C# code.

I hope this helps, Thomas

answered on Stack Overflow Mar 4, 2020 by Thomas Claudius Huber • edited Mar 4, 2020 by Thomas Claudius Huber

User contributions licensed under CC BY-SA 3.0