Using a .Net 4.x WCF client assembly in .Net 6?

Viewed 14

Our desktop app talks to a piece of software on a remote PC (which in turn controls an industrial device). Our app references a "client assembly" that was provided by the manufacturer, and is essentially an API exposing numerous methods, using WCF under the covers (over TCP). The target framework of this 3rd-party client assembly is .Net 4.5.

I'm in the process of migrating our desktop app to .Net6, and initially encountered the following exception on startup:

System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

This was fixed by adding the "System.ServiceModel.Primitives" NuGet package. (I had a similar exception for "System.ServiceModel.NetTcp", again fixed by adding that package).

I've run the portability analyzer (ApiPort) on the 3rd-party assembly, and every one of the messages relates to System.ServiceModel, e.g.:

"DefinedInAssemblyIdentity": "System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 
"MemberDocId": "T:System.ServiceModel.MessageSecurityOverTcp",
  "TypeDocId": null,
  "RecommendedChanges": "This part of Windows Communication Foundation (WCF) won't be ported to .NET Core. See https://aka.ms/unsupported-netfx-api.",
  "SourceCompatibleChange": "",
  "TargetStatus": [
    null
  ]

With this in mind, and having added the earlier NuGet packages, how confident can I be that this assembly will work happily in our .Net 6 app? (It's going to be a while before I can actually test this area of the migrated app for real).

1 Answers

.NET 6 support for WCF is less comprehensive, despite Microsoft's efforts. The mainstream option is CoreWCF. There are still some issues, but some common features of WCF are supported.

There are other options, such as gRPC, which has the advantage of being flexible and can be used across platforms and frameworks.

Related