0

In an ASP.NET Core 3.1 website project I use connected services for legacy WFC. In VS I choose Add -> Connected Service. When adding the service I set the CollectionMappings to Generic.List so that the proxy creates List<T> types instead of arrays.

Today I went to update the connected service, which I normally do by deleting it first and then re-creating it (there is no edit/update option). However, things have changed. Add -> Connected Service is gone - replaced with Manage Connected Services.

But now when adding the service - despite choosing "Generic.List", the proxy generates arrays. Which results in a thousand lines of my code now underlined in red.

I searched the Net for this issue and found some references from 2010 and a few years ago but I couldn't find any solutions.

The generated classes still have [System.Runtime.Serialization.DataContractAttribute... so I don't think it's using XmlSerializer - which apparently doesn't honor the Collection Mapping settings.

I also noticed that the Svcutil version has changed. It used to be 2.0.2 and is now 2.0.3

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3-preview3.21351.2")]

The only work-around I can think of for now is to manually update the Reference.cs file and make the following find/replace changes:

System.Threading.Tasks.Task<T[]>

...to:

Task<System.Collections.Generic.List<T>

Anyone have experience with this? It appears to be a bug in the Svcutil update (note the preview3.21351.2). And if Collection Mappings are no longer supported why are they still showing in the dialog?

Dai
  • 141,631
  • 28
  • 261
  • 374
Ross Kelly
  • 477
  • 1
  • 6
  • 23
  • WCF _really_ doesn't play-nice with modern C# code . I recommend you create the WCF service-proxy and contract-types in a separate `.csproj` project and then reference that from your ASP.NET Core project. But yes, there likely are issues with the preview build of `svcutil` you're somehow using. – Dai Oct 17 '21 at 14:48
  • Another option is to install an older version of VS that you know worked (install it in a VM, don't risk side-by-side VS installs breaking your system) and generate the code in there, then copy the files over. – Dai Oct 17 '21 at 14:49
  • @Dai thanks for the feedback - good work-around ideas. I think an older version of VS on a VM is probably easiest. so annoying when MS breaks things. If my client would spend the money I'd rewrite their legacy WCF into a more modern Core Restful Web API. But its a big job and they'd have to also update the clients that consume it. – Ross Kelly Oct 17 '21 at 15:00

0 Answers0